<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ahay.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nick</id>
	<title>Madagascar - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://ahay.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nick"/>
	<link rel="alternate" type="text/html" href="https://ahay.org/wiki/Special:Contributions/Nick"/>
	<updated>2026-04-16T01:19:39Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.7</generator>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=2658</id>
		<title>Guide to madagascar API</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=2658"/>
		<updated>2013-10-06T11:57:59Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Fortran-90 interface */ Good practice -- always explicitly deallocate arrays&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://sourceforge.net/p/rsf/code/HEAD/tree/trunk/book/rsf/rsf/api.tex book/rsf/rsf/api.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Fotolia_555071_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
This guide explains the RSF programming interface.  See the &#039;&#039;&#039;[[Library_Reference | Library Reference]]&#039;&#039;&#039; for more information on how to use the particular APIs.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To work with RSF files in your own programs, you may need to use an&lt;br /&gt;
appropriate programming interface. We will demonstrate the interface in&lt;br /&gt;
different languages using a simple example. The example is a clipping program.&lt;br /&gt;
It reads and writes RSF files and accesses parameters both from the input file&lt;br /&gt;
and the command line. The input is processed trace by trace. This is not&lt;br /&gt;
necessarily the most efficient approach&amp;lt;ref&amp;gt;Compare with the [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/filt/proc/Mclip.c?view=markup library clip program].&amp;lt;/ref&amp;gt; but it suffices for a simple demonstration.&lt;br /&gt;
&lt;br /&gt;
==Installation== &lt;br /&gt;
Only the C interface is installed by default. To install other APIs, use &amp;lt;tt&amp;gt;API=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameter in the RSF configuration. For example, to install C++ and&lt;br /&gt;
Fortran-90 API bindings in addition to the basic package, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure API=c++,fortran-90&lt;br /&gt;
scons install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The configuration parameters are stored in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C interface==&lt;br /&gt;
&lt;br /&gt;
The C clip function is listed below.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    int n1, n2, i1, i2;&lt;br /&gt;
    float clip, *trace=NULL;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    free(trace);&lt;br /&gt;
    sf_close();&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The include preprocessing directive is required to access the RSF interface. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF data files are defined with an abstract &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; data type. An&lt;br /&gt;
abstract data type means that the contents of it are not publicly declared,&lt;br /&gt;
and all operations on &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; objects should be performed with&lt;br /&gt;
library functions. This is analogous to &amp;lt;tt&amp;gt;FILE *&amp;lt;/tt&amp;gt; data type used in&lt;br /&gt;
&amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; and as close as C gets to an object-oriented style of&lt;br /&gt;
programming (Roberts, 1998&amp;lt;ref&amp;gt;Roberts, E. S.,  1998, Programming abstractions in C: Addison-Wesley.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any of the other functions, you must call&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;. This function parses the command line and&lt;br /&gt;
initializes an internally stored table of command-line parameters.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output RSF file objects are created with &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt; constructor functions. Both these functions take a string&lt;br /&gt;
argument. The string may refer to a file name or a file tag. For example, if&lt;br /&gt;
the command line contains &amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the standard&lt;br /&gt;
output. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). We extract the data type of the input file&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; function and check if it&lt;br /&gt;
represents floating point numbers. If not, the program is aborted with&lt;br /&gt;
an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function. Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt; returns the total number of elements in&lt;br /&gt;
the hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product&lt;br /&gt;
of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we avoid the need&lt;br /&gt;
to extract additional parameters for the hypercube dimensions that we&lt;br /&gt;
are not interested in.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Next, we allocate an array of floating-point numbers to store a trace&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_floatalloc&amp;lt;/tt&amp;gt; function. Unlike the standard&lt;br /&gt;
&amp;lt;tt&amp;gt;malloc&amp;lt;/tt&amp;gt; the RSF allocation function checks for errors and&lt;br /&gt;
either terminates the program or returns a valid pointer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The rest of the program is straightforward. We loop over all available&lt;br /&gt;
traces, read each trace, clip it and right the output out. The syntax&lt;br /&gt;
of &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt; functions is&lt;br /&gt;
similar to the syntax of the C standard &amp;lt;tt&amp;gt;fread&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;fwrite&amp;lt;/tt&amp;gt; function except that the type of the element is&lt;br /&gt;
specified explicitly in the function name and that the input and&lt;br /&gt;
output files have the RSF type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
sf_close();&lt;br /&gt;
exit(0)&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We explicitly close the input file to avoid leaving a stale temporary file in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; if the program is called in a pipe sequence. Then, we close the program by sending the shell the Unix code that tells it no errors were encountered. &lt;br /&gt;
&lt;br /&gt;
Note that this is an introductory example, optimized for clarity, not execution speed. For advanced techniques, see [[Madagascar Code Patterns]].&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt; program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cc clip.c -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;cc&amp;lt;/tt&amp;gt; to the C compiler appropriate for your system and include&lt;br /&gt;
additional compiler flags if necessary. The flags that RSF typically uses are&lt;br /&gt;
in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C++ interface==&lt;br /&gt;
&lt;br /&gt;
The C++ clip function is listed below.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;valarray&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
    &lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&lt;br /&gt;
    int n1, n2;      // trace length, number of traces&lt;br /&gt;
    float clip;&lt;br /&gt;
    &lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it line by line. &lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Including &amp;quot;&amp;lt;tt&amp;gt;rsf.hh&amp;lt;/tt&amp;gt;&amp;quot; is required for accessing the RSF C++&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is required to initialize the internally stored&lt;br /&gt;
table of command-line arguments.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Two classes: &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;oRSF&amp;lt;/tt&amp;gt; are used to define input and&lt;br /&gt;
output files. For simplicity, the command-line parameters are also handled &lt;br /&gt;
as an &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; object, initialized with zero.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we read the data dimensions from the input RSF file object called&lt;br /&gt;
&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;: the trace length is a parameter called &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; and the&lt;br /&gt;
number of traces is the size of &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; remaining after excluding the&lt;br /&gt;
first dimension. It is extracted with the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter should be specified on the command line, for&lt;br /&gt;
example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. It is extracted with the &amp;lt;tt&amp;gt;get&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; class from the &amp;lt;tt&amp;gt;par&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace object has the single-precision floating-point type and is a&lt;br /&gt;
1-D array of length &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;. It is declared and allocated using&lt;br /&gt;
the &amp;lt;tt&amp;gt;valarray&amp;lt;/tt&amp;gt; template class from the standard C++ library.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we loop through the traces, read each trace from &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;, clip it&lt;br /&gt;
and write the output to &amp;lt;tt&amp;gt;out&amp;lt;/tt&amp;gt;.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the C++ program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
c++ clip.cc -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf++ -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;c++&amp;lt;/tt&amp;gt; to the C++ compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-77 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-77 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	program Clipit&lt;br /&gt;
	implicit none&lt;br /&gt;
	integer n1, n2, i1, i2, in, out&lt;br /&gt;
	integer sf_input, sf_output, sf_leftsize, sf_gettype&lt;br /&gt;
	logical sf_getfloat, sf_histint&lt;br /&gt;
	real clip, trace(1000)&lt;br /&gt;
&lt;br /&gt;
	call sf_init()&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&lt;br /&gt;
	stop&lt;br /&gt;
	end&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	call sf_init()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with a call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;, which initializes the&lt;br /&gt;
command-line interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output files are created with calls to&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;. Because of the absence of&lt;br /&gt;
derived types in Fortran-77, we use simple integer pointers to&lt;br /&gt;
represent RSF files. Both &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;&lt;br /&gt;
accept a character string, which may refer to a file name or a file&lt;br /&gt;
tag. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in&lt;br /&gt;
the standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard output.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). The function &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; checks the&lt;br /&gt;
type of data stored in the RSF file. We make sure that the type&lt;br /&gt;
corresponds to floating-point numbers. If not, the program is aborted&lt;br /&gt;
with an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. Since Fortran-77 cannot&lt;br /&gt;
easily handle dynamic allocation, we also need to check that&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is not larger than the size of the statically allocated&lt;br /&gt;
array. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function.  Calling &amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we&lt;br /&gt;
avoid the need to extract additional parameters for the hypercube&lt;br /&gt;
dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-77 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f77 clip.f -L$RSFROOT/lib -lrsff -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f77&amp;lt;/tt&amp;gt; to the Fortran compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-90 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-90 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
program Clipit&lt;br /&gt;
  use rsf&lt;br /&gt;
&lt;br /&gt;
  implicit none&lt;br /&gt;
  type (file)                      :: in, out&lt;br /&gt;
  integer                          :: n1, n2, i1, i2&lt;br /&gt;
  real                             :: clip&lt;br /&gt;
  real, dimension (:), allocatable :: trace&lt;br /&gt;
&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  call from_par(in,&amp;quot;n1&amp;quot;,n1)&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&lt;br /&gt;
  call from_par(&amp;quot;clip&amp;quot;,clip) ! command-line parameter &lt;br /&gt;
&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
     call rsf_write(out,trace)&lt;br /&gt;
  end do&lt;br /&gt;
&lt;br /&gt;
  deallocate (trace)&lt;br /&gt;
&lt;br /&gt;
end program Clipit&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  use rsf&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with importing the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is needed to initialize the command-line&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard input and output files are initialized with&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; functions. Both functions&lt;br /&gt;
accept optional arguments. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; extracts the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter&lt;br /&gt;
from the input file. Conceptually, the RSF data model is a&lt;br /&gt;
multidimensional hypercube.  The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace length. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; function.  Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in)&amp;lt;/tt&amp;gt; returns the total number of elements in the&lt;br /&gt;
hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;filesize(in,2)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt;, we avoid the need to extract additional parameters&lt;br /&gt;
for the hypercube dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. If we knew a good default&lt;br /&gt;
value for &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt;, we could specify it with an optional&lt;br /&gt;
argument, i.e. &amp;lt;tt&amp;gt;call~from_par(&amp;quot;clip&amp;quot;,clip,default)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-90 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f90 clip.f90 -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsff90 -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f90&amp;lt;/tt&amp;gt; to the Fortran-90 compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagasacar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The complete specification for the F90 API can be found [[Library_Reference#Fortran_90_API | on the Library Reference page]].&lt;br /&gt;
&lt;br /&gt;
==Python interface==&lt;br /&gt;
&lt;br /&gt;
The Python clip script is listed below.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&lt;br /&gt;
trace = numpy.zeros(n1,&#039;f&#039;)&lt;br /&gt;
&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script starts with importing the &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; module and the&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we initialize the command line interface and the standard input and&lt;br /&gt;
output files. We also make sure that the input file type is floating point.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We extract the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter from the input file.&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube.  The&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the fastest axis. If the input dataset&lt;br /&gt;
is a collection of traces, &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace&lt;br /&gt;
length. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of the &amp;lt;tt&amp;gt;Input&amp;lt;/tt&amp;gt; class1.  Calling &amp;lt;tt&amp;gt;size(0)&amp;lt;/tt&amp;gt; returns&lt;br /&gt;
the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;size(1)&amp;lt;/tt&amp;gt; returns the&lt;br /&gt;
number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.),&lt;br /&gt;
calling &amp;lt;tt&amp;gt;size(2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be specified,&lt;br /&gt;
for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
The python script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Interactive mode usage without graphics===&lt;br /&gt;
Madagascar&#039;s Python API can be used interactively too. Create an input dataset with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=10 n2=10 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start the python interpreter and paste the following to its command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy, rsf.api&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
data = data.transpose() # Example of numpy in action&lt;br /&gt;
&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.]&lt;br /&gt;
 [  1.   2.   3.   4.   5.   6.   7.   8.   9.  10.]&lt;br /&gt;
 [  2.   3.   4.   5.   6.   7.   8.   9.  10.  11.]&lt;br /&gt;
 [  3.   4.   5.   6.   7.   8.   9.  10.  11.  12.]&lt;br /&gt;
 [  4.   5.   6.   7.   8.   9.  10.  11.  12.  13.]&lt;br /&gt;
 [  5.   6.   7.   8.   9.  10.  11.  12.  13.  14.]&lt;br /&gt;
 [  6.   7.   8.   9.  10.  11.  12.  13.  14.  15.]&lt;br /&gt;
 [  7.   8.   9.  10.  11.  12.  13.  14.  15.  16.]&lt;br /&gt;
 [  8.   9.  10.  11.  12.  13.  14.  15.  16.  17.]&lt;br /&gt;
 [  9.  10.  11.  12.  13.  14.  15.  16.  17.  18.]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will also work in batch mode in a Python script, not only pasted to the interpreter&#039;s command line. &lt;br /&gt;
&lt;br /&gt;
===Graphics with Matplotlib===&lt;br /&gt;
Python can plot arrays directly from memory, without having to write a file to disk first. [http://matplotlib.sourceforge.net/ Matplotlib] is one of the [http://en.wikipedia.org/wiki/Category:Free_plotting_software several] packages that accomplish this. To create a figure, execute the code in the previous section, followed by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from pylab import *&lt;br /&gt;
imshow(data)&lt;br /&gt;
xlabel(&#039;X (m)&#039;)&lt;br /&gt;
ylabel(&#039;Y (m)&#039;)&lt;br /&gt;
title(&#039;Matplotlib example&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pop up a figure in an interactive session, after pasting to a Python command line the code shown before, also paste:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get Figure 1. The figure will pop up if you run the code in a script too, and the script will stop until the figure is manually closed. You must press the floppy disk button in order to save it. To have the image written to disk automatically, instead of &amp;lt;tt&amp;gt;show()&amp;lt;/tt&amp;gt; use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
savefig(&#039;myfile.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:matplotlib_imshow.png]]&lt;br /&gt;
&lt;br /&gt;
Putting it all together, here is a sample script reading a RSF file from stdin and printing out a figure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rsf.api, numpy, sys, pylab&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
&lt;br /&gt;
pylab.imshow(data)&lt;br /&gt;
pylab.savefig(&#039;out.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
===Python interfaces to the standalone programs===&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module offers a way to call Madagascar standalone programs (including graphics) elegantly from inside a Python program, interactively or in batch mode. The blog contains examples of running the &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module [http://www.ahay.org/rsflog/index.php?/archives/173-Extending-Python-interface.html from inside a SAGE notebook] or [http://www.ahay.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html from inside an iPython shell].&lt;br /&gt;
&lt;br /&gt;
==MATLAB interface==&lt;br /&gt;
&lt;br /&gt;
The MATLAB clip function is listed below.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
function clip(in,out,clip)&lt;br /&gt;
%CLIP Clip the data&lt;br /&gt;
&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by figuring out the input file dimensions.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first dimension is the trace length, the product of all other&lt;br /&gt;
dimensions correspond to the number of traces.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we allocate the trace array and create an output file.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Available functions===&lt;br /&gt;
Only some of the functions in the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; library have received a MATLAB interface. These functions are &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt;. All these functions except &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; have been illustrated in the example above.&lt;br /&gt;
===Compiling===&lt;br /&gt;
The MATLAB script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Java Interface==&lt;br /&gt;
There are two interfaces to Java that are available.  New codes should be written to use the SWIG interface ONLY.  The older interface (using the MINES JTK) is deprecated, and is only provided while users migrate their code to the new interface.&lt;br /&gt;
&lt;br /&gt;
===SWIG===&lt;br /&gt;
&lt;br /&gt;
To install the SWIG interface:&lt;br /&gt;
&lt;br /&gt;
1 - Download the Java Standard Development Kit (JDK).  Installation varies by platform.&lt;br /&gt;
&lt;br /&gt;
2 - Create the JAVA_HOME environment variable for your shell.  This should point to the directory where the JDK was installed. Example (for Ubuntu 10.04):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export JAVA_HOME=/usr/lib/jvm/java-6-opensdk&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
3 - Reconfigure Madagascar:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
4 - Reinstall Madagascar (Ignore the compilation warnings for Java files):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
scons; scons install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation creates two files:  $RSFROOT/lib/libjrsf.so and $RSFROOT/lib/rsf.jar .&lt;br /&gt;
&lt;br /&gt;
Make sure that you set your LD_LIBRARY_PATH to include $RSFROOT/lib.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A short demonstration of the interface follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.RSF;&lt;br /&gt;
import rsf.Input;&lt;br /&gt;
import rsf.Output;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset. */&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    static {&lt;br /&gt;
        System.loadLibrary(&amp;quot;jrsf&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         RSF par = new RSF(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         Input input = new Input(&amp;quot;in&amp;quot;);&lt;br /&gt;
         Output output = new Output(&amp;quot;out&amp;quot;);&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        // Read our input header&lt;br /&gt;
        int n3 = input.getN(3);&lt;br /&gt;
        int n2 = input.getN(2);&lt;br /&gt;
        int n1 = input.getN(1);&lt;br /&gt;
        //Perform clipping operation on a single trace and write out.&lt;br /&gt;
        float[] data = new float[n1];&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                input.read(data);&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    if (data[k] &amp;gt; clip) data[k] = clip;&lt;br /&gt;
                    else if (data[k] &amp;lt; -clip) data[k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
                output.write(data);&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         output.setN(1,n1);&lt;br /&gt;
         output.setN(2,n2);&lt;br /&gt;
         output.setN(3,n3);&lt;br /&gt;
         input.close();&lt;br /&gt;
         output.close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are only three classes in the interface:&lt;br /&gt;
&lt;br /&gt;
1 -- RSF - The command line argument parser, and the initializer for the native interface.  An RSF object MUST be instantiated BEFORE instantiating an Input or Output object.&lt;br /&gt;
&lt;br /&gt;
2 -- Input - An object that provides read access to an RSF file.  &lt;br /&gt;
&lt;br /&gt;
3 -- Output - An object that provides write access to an RSF file.&lt;br /&gt;
&lt;br /&gt;
Additionally, the shared library (libjrsf.so or libjrsf.dll) must be included via the System.loadLibrary(&amp;quot;jrsf&amp;quot;); as the first command in the file.&lt;br /&gt;
&lt;br /&gt;
To compile on the command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $RSFROOT/lib Clip.java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To include this as part of a SCons script (SConstruct):&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500 l1=1000&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;dat Clip.class&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s Clip clip=0.5&lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;))&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that we compile Clip.java using the SCons Java builder.  To execute the command, we have to locate the &amp;quot;java&amp;quot; command, which we do using WhereIs(&#039;java&#039;).  Then we execute the class name, and pass any command line arguments as usual.  The files are read from standard in for this program and written to standard out.  &lt;br /&gt;
&lt;br /&gt;
Please see the [[Library Reference]] for more details on the functions available in the SWIG API.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: Additional Java packages can included in SCons automatically by setting the CLASSPATH environment variable to point to the JAR files that they are contained in.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Mines JTK===&lt;br /&gt;
&#039;&#039;&#039;THIS INTERFACE IS DEPRECATED AND ONLY PROVIDED AS A REFERENCE.  THIS INTERFACE IS NO LONGER SUPPORTED AND WILL BE REMOVED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This interface may still be compiled by specifying the MINESJTK environment variable. &lt;br /&gt;
&lt;br /&gt;
The interface to Java is less full featured than others.  Presently, it only allows you to read RSF files with fewer than 4-dimensions into Java, and then export RSF files.  &#039;&#039;&#039;The Java interface does not support reading from standard in, or writing from standard out.  Therefore, the Java Interface does not support piping either.&#039;&#039;&#039; The Java interface at present treats all values as floats, and does not have support for complex numbers.  Java programs are not parsed for self-doc information like other programs are either.  Using javadoc may be a viable alternative to creating a parsing engine for Java programs.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, the JAR file rsf.jar will be added to your $RSFROOT/lib folder.  &lt;br /&gt;
&lt;br /&gt;
There are two ways to access the API:&lt;br /&gt;
&lt;br /&gt;
1 - From the command line:  point the classpath at BOTH compile and runtime to this location on the command line.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test.java &lt;br /&gt;
java -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test arg1=... arg2=... arg3=...&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2 - From within a SConstruct script:  BOTH the path for the API ($RSFROOT/lib) and the path to the Mines JTK ($MINESJTK) are automatically added to the environment variable CLASSPATH and JAVACLASSPATH for executions made within an SConstruct.  Additionally, any additional classes that are already in the CLASSPATH environmental variable in the shell that you launch from will be added to your classpath.  This allows you to include additional libraries automatically within your Java programs.  The local directory (.) is also included in the CLASSPATH.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;Clip.class dat&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s ${SOURCES[0].filebase} clip=0.5 &lt;br /&gt;
    in=${SOURCES[1]} out=$TARGET &lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;),stdin=0,stdout=-1)&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface itself is fairly straightforward.  More details on the methods exposed by the API can be found at the [[Library_Reference#Java_API | Library Reference]].&lt;br /&gt;
&lt;br /&gt;
Data clipping, argument parsing, and IO example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Par;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset.&lt;br /&gt;
&lt;br /&gt;
Presently, there is no automatic self-documentation generation for use&lt;br /&gt;
with sfdoc.  Javadoc may be a better way to generate self-doc for Java&lt;br /&gt;
programs.&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         Par par = new Par(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         String input = par.getString(&amp;quot;in&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         // If the input file name is nothing, then quit!&lt;br /&gt;
         if (input.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find input file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
         //If the output file name is nothing, then quit!&lt;br /&gt;
         String output = par.getString(&amp;quot;out&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         if (output.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find output file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        //Read our header file.&lt;br /&gt;
         Header header = Reader.readHeader(input);&lt;br /&gt;
        // Read our binary data.&lt;br /&gt;
         float[][][] data = Reader.readBinary3D(header);&lt;br /&gt;
        //Initialize our array values.&lt;br /&gt;
         int n3 = header.getN(3);&lt;br /&gt;
         int n2 = header.getN(2);&lt;br /&gt;
         int n1 = header.getN(1);&lt;br /&gt;
        //Perform clipping operation.&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    float trace = data[i][j][k];&lt;br /&gt;
                    if (trace &amp;gt; clip) data[i][j][k] = clip;&lt;br /&gt;
                    else if (trace &amp;lt; -clip) data[i][j][k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
        //Write our data out, using the same header values to the file&lt;br /&gt;
        //located at: output.&lt;br /&gt;
         Writer.writeRSF(header,data,output);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to read a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;junk.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to write a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
                &lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;test.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;test2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to create a dataset from scratch from within Java, then you can create an array of data, modify the values, create a header, and then write it out to rsf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                int n1 = 20;&lt;br /&gt;
                int n2 = 40;&lt;br /&gt;
                float[][] data = new float[n2][n1]; &lt;br /&gt;
                //The order for dimensions is reversed, because RSF stores them as column-major arrays (see Python API).&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
&lt;br /&gt;
                Header header = new Header();&lt;br /&gt;
                header.setN(1,n1);&lt;br /&gt;
                /* We set the values using the proper RSF number for the dimension, instead of the Java array index.&lt;br /&gt;
                   Example:  RSF Dimension 1, corresponds to array index 0 in Java.&lt;br /&gt;
                             However, we set the values using index 1.  The mapping is handled behind the scenes.&lt;br /&gt;
                 */&lt;br /&gt;
                header.setN(2,n2); &lt;br /&gt;
                header.setDelta(1,0.0);&lt;br /&gt;
                header.setLabel(1,&amp;quot;time&amp;quot;);&lt;br /&gt;
                header.setUnits(1,&amp;quot;s&amp;quot;);&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;junk2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=2657</id>
		<title>Guide to madagascar API</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=2657"/>
		<updated>2013-10-06T11:57:14Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* C interface */ Good practice -- always explicitly deallocate arrays&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://sourceforge.net/p/rsf/code/HEAD/tree/trunk/book/rsf/rsf/api.tex book/rsf/rsf/api.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Fotolia_555071_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
This guide explains the RSF programming interface.  See the &#039;&#039;&#039;[[Library_Reference | Library Reference]]&#039;&#039;&#039; for more information on how to use the particular APIs.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To work with RSF files in your own programs, you may need to use an&lt;br /&gt;
appropriate programming interface. We will demonstrate the interface in&lt;br /&gt;
different languages using a simple example. The example is a clipping program.&lt;br /&gt;
It reads and writes RSF files and accesses parameters both from the input file&lt;br /&gt;
and the command line. The input is processed trace by trace. This is not&lt;br /&gt;
necessarily the most efficient approach&amp;lt;ref&amp;gt;Compare with the [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/filt/proc/Mclip.c?view=markup library clip program].&amp;lt;/ref&amp;gt; but it suffices for a simple demonstration.&lt;br /&gt;
&lt;br /&gt;
==Installation== &lt;br /&gt;
Only the C interface is installed by default. To install other APIs, use &amp;lt;tt&amp;gt;API=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameter in the RSF configuration. For example, to install C++ and&lt;br /&gt;
Fortran-90 API bindings in addition to the basic package, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure API=c++,fortran-90&lt;br /&gt;
scons install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The configuration parameters are stored in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C interface==&lt;br /&gt;
&lt;br /&gt;
The C clip function is listed below.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    int n1, n2, i1, i2;&lt;br /&gt;
    float clip, *trace=NULL;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    free(trace);&lt;br /&gt;
    sf_close();&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The include preprocessing directive is required to access the RSF interface. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF data files are defined with an abstract &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; data type. An&lt;br /&gt;
abstract data type means that the contents of it are not publicly declared,&lt;br /&gt;
and all operations on &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; objects should be performed with&lt;br /&gt;
library functions. This is analogous to &amp;lt;tt&amp;gt;FILE *&amp;lt;/tt&amp;gt; data type used in&lt;br /&gt;
&amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; and as close as C gets to an object-oriented style of&lt;br /&gt;
programming (Roberts, 1998&amp;lt;ref&amp;gt;Roberts, E. S.,  1998, Programming abstractions in C: Addison-Wesley.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any of the other functions, you must call&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;. This function parses the command line and&lt;br /&gt;
initializes an internally stored table of command-line parameters.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output RSF file objects are created with &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt; constructor functions. Both these functions take a string&lt;br /&gt;
argument. The string may refer to a file name or a file tag. For example, if&lt;br /&gt;
the command line contains &amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the standard&lt;br /&gt;
output. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). We extract the data type of the input file&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; function and check if it&lt;br /&gt;
represents floating point numbers. If not, the program is aborted with&lt;br /&gt;
an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function. Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt; returns the total number of elements in&lt;br /&gt;
the hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product&lt;br /&gt;
of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we avoid the need&lt;br /&gt;
to extract additional parameters for the hypercube dimensions that we&lt;br /&gt;
are not interested in.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Next, we allocate an array of floating-point numbers to store a trace&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_floatalloc&amp;lt;/tt&amp;gt; function. Unlike the standard&lt;br /&gt;
&amp;lt;tt&amp;gt;malloc&amp;lt;/tt&amp;gt; the RSF allocation function checks for errors and&lt;br /&gt;
either terminates the program or returns a valid pointer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The rest of the program is straightforward. We loop over all available&lt;br /&gt;
traces, read each trace, clip it and right the output out. The syntax&lt;br /&gt;
of &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt; functions is&lt;br /&gt;
similar to the syntax of the C standard &amp;lt;tt&amp;gt;fread&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;fwrite&amp;lt;/tt&amp;gt; function except that the type of the element is&lt;br /&gt;
specified explicitly in the function name and that the input and&lt;br /&gt;
output files have the RSF type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
sf_close();&lt;br /&gt;
exit(0)&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We explicitly close the input file to avoid leaving a stale temporary file in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; if the program is called in a pipe sequence. Then, we close the program by sending the shell the Unix code that tells it no errors were encountered. &lt;br /&gt;
&lt;br /&gt;
Note that this is an introductory example, optimized for clarity, not execution speed. For advanced techniques, see [[Madagascar Code Patterns]].&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt; program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cc clip.c -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;cc&amp;lt;/tt&amp;gt; to the C compiler appropriate for your system and include&lt;br /&gt;
additional compiler flags if necessary. The flags that RSF typically uses are&lt;br /&gt;
in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C++ interface==&lt;br /&gt;
&lt;br /&gt;
The C++ clip function is listed below.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;valarray&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
    &lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&lt;br /&gt;
    int n1, n2;      // trace length, number of traces&lt;br /&gt;
    float clip;&lt;br /&gt;
    &lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it line by line. &lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Including &amp;quot;&amp;lt;tt&amp;gt;rsf.hh&amp;lt;/tt&amp;gt;&amp;quot; is required for accessing the RSF C++&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is required to initialize the internally stored&lt;br /&gt;
table of command-line arguments.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Two classes: &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;oRSF&amp;lt;/tt&amp;gt; are used to define input and&lt;br /&gt;
output files. For simplicity, the command-line parameters are also handled &lt;br /&gt;
as an &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; object, initialized with zero.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we read the data dimensions from the input RSF file object called&lt;br /&gt;
&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;: the trace length is a parameter called &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; and the&lt;br /&gt;
number of traces is the size of &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; remaining after excluding the&lt;br /&gt;
first dimension. It is extracted with the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter should be specified on the command line, for&lt;br /&gt;
example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. It is extracted with the &amp;lt;tt&amp;gt;get&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; class from the &amp;lt;tt&amp;gt;par&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace object has the single-precision floating-point type and is a&lt;br /&gt;
1-D array of length &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;. It is declared and allocated using&lt;br /&gt;
the &amp;lt;tt&amp;gt;valarray&amp;lt;/tt&amp;gt; template class from the standard C++ library.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we loop through the traces, read each trace from &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;, clip it&lt;br /&gt;
and write the output to &amp;lt;tt&amp;gt;out&amp;lt;/tt&amp;gt;.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the C++ program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
c++ clip.cc -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf++ -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;c++&amp;lt;/tt&amp;gt; to the C++ compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-77 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-77 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	program Clipit&lt;br /&gt;
	implicit none&lt;br /&gt;
	integer n1, n2, i1, i2, in, out&lt;br /&gt;
	integer sf_input, sf_output, sf_leftsize, sf_gettype&lt;br /&gt;
	logical sf_getfloat, sf_histint&lt;br /&gt;
	real clip, trace(1000)&lt;br /&gt;
&lt;br /&gt;
	call sf_init()&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&lt;br /&gt;
	stop&lt;br /&gt;
	end&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	call sf_init()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with a call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;, which initializes the&lt;br /&gt;
command-line interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output files are created with calls to&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;. Because of the absence of&lt;br /&gt;
derived types in Fortran-77, we use simple integer pointers to&lt;br /&gt;
represent RSF files. Both &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;&lt;br /&gt;
accept a character string, which may refer to a file name or a file&lt;br /&gt;
tag. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in&lt;br /&gt;
the standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard output.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). The function &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; checks the&lt;br /&gt;
type of data stored in the RSF file. We make sure that the type&lt;br /&gt;
corresponds to floating-point numbers. If not, the program is aborted&lt;br /&gt;
with an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. Since Fortran-77 cannot&lt;br /&gt;
easily handle dynamic allocation, we also need to check that&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is not larger than the size of the statically allocated&lt;br /&gt;
array. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function.  Calling &amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we&lt;br /&gt;
avoid the need to extract additional parameters for the hypercube&lt;br /&gt;
dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-77 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f77 clip.f -L$RSFROOT/lib -lrsff -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f77&amp;lt;/tt&amp;gt; to the Fortran compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-90 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-90 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
program Clipit&lt;br /&gt;
  use rsf&lt;br /&gt;
&lt;br /&gt;
  implicit none&lt;br /&gt;
  type (file)                      :: in, out&lt;br /&gt;
  integer                          :: n1, n2, i1, i2&lt;br /&gt;
  real                             :: clip&lt;br /&gt;
  real, dimension (:), allocatable :: trace&lt;br /&gt;
&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  call from_par(in,&amp;quot;n1&amp;quot;,n1)&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&lt;br /&gt;
  call from_par(&amp;quot;clip&amp;quot;,clip) ! command-line parameter &lt;br /&gt;
&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
     call rsf_write(out,trace)&lt;br /&gt;
  end do&lt;br /&gt;
end program Clipit&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  use rsf&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with importing the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is needed to initialize the command-line&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard input and output files are initialized with&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; functions. Both functions&lt;br /&gt;
accept optional arguments. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; extracts the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter&lt;br /&gt;
from the input file. Conceptually, the RSF data model is a&lt;br /&gt;
multidimensional hypercube.  The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace length. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; function.  Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in)&amp;lt;/tt&amp;gt; returns the total number of elements in the&lt;br /&gt;
hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;filesize(in,2)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt;, we avoid the need to extract additional parameters&lt;br /&gt;
for the hypercube dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. If we knew a good default&lt;br /&gt;
value for &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt;, we could specify it with an optional&lt;br /&gt;
argument, i.e. &amp;lt;tt&amp;gt;call~from_par(&amp;quot;clip&amp;quot;,clip,default)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-90 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f90 clip.f90 -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsff90 -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f90&amp;lt;/tt&amp;gt; to the Fortran-90 compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagasacar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The complete specification for the F90 API can be found [[Library_Reference#Fortran_90_API | on the Library Reference page]].&lt;br /&gt;
&lt;br /&gt;
==Python interface==&lt;br /&gt;
&lt;br /&gt;
The Python clip script is listed below.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&lt;br /&gt;
trace = numpy.zeros(n1,&#039;f&#039;)&lt;br /&gt;
&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script starts with importing the &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; module and the&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we initialize the command line interface and the standard input and&lt;br /&gt;
output files. We also make sure that the input file type is floating point.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We extract the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter from the input file.&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube.  The&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the fastest axis. If the input dataset&lt;br /&gt;
is a collection of traces, &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace&lt;br /&gt;
length. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of the &amp;lt;tt&amp;gt;Input&amp;lt;/tt&amp;gt; class1.  Calling &amp;lt;tt&amp;gt;size(0)&amp;lt;/tt&amp;gt; returns&lt;br /&gt;
the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;size(1)&amp;lt;/tt&amp;gt; returns the&lt;br /&gt;
number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.),&lt;br /&gt;
calling &amp;lt;tt&amp;gt;size(2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be specified,&lt;br /&gt;
for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
The python script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Interactive mode usage without graphics===&lt;br /&gt;
Madagascar&#039;s Python API can be used interactively too. Create an input dataset with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=10 n2=10 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start the python interpreter and paste the following to its command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy, rsf.api&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
data = data.transpose() # Example of numpy in action&lt;br /&gt;
&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.]&lt;br /&gt;
 [  1.   2.   3.   4.   5.   6.   7.   8.   9.  10.]&lt;br /&gt;
 [  2.   3.   4.   5.   6.   7.   8.   9.  10.  11.]&lt;br /&gt;
 [  3.   4.   5.   6.   7.   8.   9.  10.  11.  12.]&lt;br /&gt;
 [  4.   5.   6.   7.   8.   9.  10.  11.  12.  13.]&lt;br /&gt;
 [  5.   6.   7.   8.   9.  10.  11.  12.  13.  14.]&lt;br /&gt;
 [  6.   7.   8.   9.  10.  11.  12.  13.  14.  15.]&lt;br /&gt;
 [  7.   8.   9.  10.  11.  12.  13.  14.  15.  16.]&lt;br /&gt;
 [  8.   9.  10.  11.  12.  13.  14.  15.  16.  17.]&lt;br /&gt;
 [  9.  10.  11.  12.  13.  14.  15.  16.  17.  18.]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will also work in batch mode in a Python script, not only pasted to the interpreter&#039;s command line. &lt;br /&gt;
&lt;br /&gt;
===Graphics with Matplotlib===&lt;br /&gt;
Python can plot arrays directly from memory, without having to write a file to disk first. [http://matplotlib.sourceforge.net/ Matplotlib] is one of the [http://en.wikipedia.org/wiki/Category:Free_plotting_software several] packages that accomplish this. To create a figure, execute the code in the previous section, followed by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from pylab import *&lt;br /&gt;
imshow(data)&lt;br /&gt;
xlabel(&#039;X (m)&#039;)&lt;br /&gt;
ylabel(&#039;Y (m)&#039;)&lt;br /&gt;
title(&#039;Matplotlib example&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pop up a figure in an interactive session, after pasting to a Python command line the code shown before, also paste:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get Figure 1. The figure will pop up if you run the code in a script too, and the script will stop until the figure is manually closed. You must press the floppy disk button in order to save it. To have the image written to disk automatically, instead of &amp;lt;tt&amp;gt;show()&amp;lt;/tt&amp;gt; use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
savefig(&#039;myfile.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:matplotlib_imshow.png]]&lt;br /&gt;
&lt;br /&gt;
Putting it all together, here is a sample script reading a RSF file from stdin and printing out a figure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rsf.api, numpy, sys, pylab&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
&lt;br /&gt;
pylab.imshow(data)&lt;br /&gt;
pylab.savefig(&#039;out.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
===Python interfaces to the standalone programs===&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module offers a way to call Madagascar standalone programs (including graphics) elegantly from inside a Python program, interactively or in batch mode. The blog contains examples of running the &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module [http://www.ahay.org/rsflog/index.php?/archives/173-Extending-Python-interface.html from inside a SAGE notebook] or [http://www.ahay.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html from inside an iPython shell].&lt;br /&gt;
&lt;br /&gt;
==MATLAB interface==&lt;br /&gt;
&lt;br /&gt;
The MATLAB clip function is listed below.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
function clip(in,out,clip)&lt;br /&gt;
%CLIP Clip the data&lt;br /&gt;
&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by figuring out the input file dimensions.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first dimension is the trace length, the product of all other&lt;br /&gt;
dimensions correspond to the number of traces.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we allocate the trace array and create an output file.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Available functions===&lt;br /&gt;
Only some of the functions in the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; library have received a MATLAB interface. These functions are &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt;. All these functions except &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; have been illustrated in the example above.&lt;br /&gt;
===Compiling===&lt;br /&gt;
The MATLAB script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Java Interface==&lt;br /&gt;
There are two interfaces to Java that are available.  New codes should be written to use the SWIG interface ONLY.  The older interface (using the MINES JTK) is deprecated, and is only provided while users migrate their code to the new interface.&lt;br /&gt;
&lt;br /&gt;
===SWIG===&lt;br /&gt;
&lt;br /&gt;
To install the SWIG interface:&lt;br /&gt;
&lt;br /&gt;
1 - Download the Java Standard Development Kit (JDK).  Installation varies by platform.&lt;br /&gt;
&lt;br /&gt;
2 - Create the JAVA_HOME environment variable for your shell.  This should point to the directory where the JDK was installed. Example (for Ubuntu 10.04):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export JAVA_HOME=/usr/lib/jvm/java-6-opensdk&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
3 - Reconfigure Madagascar:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
4 - Reinstall Madagascar (Ignore the compilation warnings for Java files):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
scons; scons install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation creates two files:  $RSFROOT/lib/libjrsf.so and $RSFROOT/lib/rsf.jar .&lt;br /&gt;
&lt;br /&gt;
Make sure that you set your LD_LIBRARY_PATH to include $RSFROOT/lib.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A short demonstration of the interface follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.RSF;&lt;br /&gt;
import rsf.Input;&lt;br /&gt;
import rsf.Output;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset. */&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    static {&lt;br /&gt;
        System.loadLibrary(&amp;quot;jrsf&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         RSF par = new RSF(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         Input input = new Input(&amp;quot;in&amp;quot;);&lt;br /&gt;
         Output output = new Output(&amp;quot;out&amp;quot;);&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        // Read our input header&lt;br /&gt;
        int n3 = input.getN(3);&lt;br /&gt;
        int n2 = input.getN(2);&lt;br /&gt;
        int n1 = input.getN(1);&lt;br /&gt;
        //Perform clipping operation on a single trace and write out.&lt;br /&gt;
        float[] data = new float[n1];&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                input.read(data);&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    if (data[k] &amp;gt; clip) data[k] = clip;&lt;br /&gt;
                    else if (data[k] &amp;lt; -clip) data[k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
                output.write(data);&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         output.setN(1,n1);&lt;br /&gt;
         output.setN(2,n2);&lt;br /&gt;
         output.setN(3,n3);&lt;br /&gt;
         input.close();&lt;br /&gt;
         output.close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are only three classes in the interface:&lt;br /&gt;
&lt;br /&gt;
1 -- RSF - The command line argument parser, and the initializer for the native interface.  An RSF object MUST be instantiated BEFORE instantiating an Input or Output object.&lt;br /&gt;
&lt;br /&gt;
2 -- Input - An object that provides read access to an RSF file.  &lt;br /&gt;
&lt;br /&gt;
3 -- Output - An object that provides write access to an RSF file.&lt;br /&gt;
&lt;br /&gt;
Additionally, the shared library (libjrsf.so or libjrsf.dll) must be included via the System.loadLibrary(&amp;quot;jrsf&amp;quot;); as the first command in the file.&lt;br /&gt;
&lt;br /&gt;
To compile on the command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $RSFROOT/lib Clip.java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To include this as part of a SCons script (SConstruct):&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500 l1=1000&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;dat Clip.class&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s Clip clip=0.5&lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;))&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that we compile Clip.java using the SCons Java builder.  To execute the command, we have to locate the &amp;quot;java&amp;quot; command, which we do using WhereIs(&#039;java&#039;).  Then we execute the class name, and pass any command line arguments as usual.  The files are read from standard in for this program and written to standard out.  &lt;br /&gt;
&lt;br /&gt;
Please see the [[Library Reference]] for more details on the functions available in the SWIG API.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: Additional Java packages can included in SCons automatically by setting the CLASSPATH environment variable to point to the JAR files that they are contained in.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Mines JTK===&lt;br /&gt;
&#039;&#039;&#039;THIS INTERFACE IS DEPRECATED AND ONLY PROVIDED AS A REFERENCE.  THIS INTERFACE IS NO LONGER SUPPORTED AND WILL BE REMOVED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This interface may still be compiled by specifying the MINESJTK environment variable. &lt;br /&gt;
&lt;br /&gt;
The interface to Java is less full featured than others.  Presently, it only allows you to read RSF files with fewer than 4-dimensions into Java, and then export RSF files.  &#039;&#039;&#039;The Java interface does not support reading from standard in, or writing from standard out.  Therefore, the Java Interface does not support piping either.&#039;&#039;&#039; The Java interface at present treats all values as floats, and does not have support for complex numbers.  Java programs are not parsed for self-doc information like other programs are either.  Using javadoc may be a viable alternative to creating a parsing engine for Java programs.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, the JAR file rsf.jar will be added to your $RSFROOT/lib folder.  &lt;br /&gt;
&lt;br /&gt;
There are two ways to access the API:&lt;br /&gt;
&lt;br /&gt;
1 - From the command line:  point the classpath at BOTH compile and runtime to this location on the command line.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test.java &lt;br /&gt;
java -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test arg1=... arg2=... arg3=...&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2 - From within a SConstruct script:  BOTH the path for the API ($RSFROOT/lib) and the path to the Mines JTK ($MINESJTK) are automatically added to the environment variable CLASSPATH and JAVACLASSPATH for executions made within an SConstruct.  Additionally, any additional classes that are already in the CLASSPATH environmental variable in the shell that you launch from will be added to your classpath.  This allows you to include additional libraries automatically within your Java programs.  The local directory (.) is also included in the CLASSPATH.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;Clip.class dat&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s ${SOURCES[0].filebase} clip=0.5 &lt;br /&gt;
    in=${SOURCES[1]} out=$TARGET &lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;),stdin=0,stdout=-1)&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface itself is fairly straightforward.  More details on the methods exposed by the API can be found at the [[Library_Reference#Java_API | Library Reference]].&lt;br /&gt;
&lt;br /&gt;
Data clipping, argument parsing, and IO example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Par;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset.&lt;br /&gt;
&lt;br /&gt;
Presently, there is no automatic self-documentation generation for use&lt;br /&gt;
with sfdoc.  Javadoc may be a better way to generate self-doc for Java&lt;br /&gt;
programs.&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         Par par = new Par(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         String input = par.getString(&amp;quot;in&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         // If the input file name is nothing, then quit!&lt;br /&gt;
         if (input.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find input file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
         //If the output file name is nothing, then quit!&lt;br /&gt;
         String output = par.getString(&amp;quot;out&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         if (output.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find output file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        //Read our header file.&lt;br /&gt;
         Header header = Reader.readHeader(input);&lt;br /&gt;
        // Read our binary data.&lt;br /&gt;
         float[][][] data = Reader.readBinary3D(header);&lt;br /&gt;
        //Initialize our array values.&lt;br /&gt;
         int n3 = header.getN(3);&lt;br /&gt;
         int n2 = header.getN(2);&lt;br /&gt;
         int n1 = header.getN(1);&lt;br /&gt;
        //Perform clipping operation.&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    float trace = data[i][j][k];&lt;br /&gt;
                    if (trace &amp;gt; clip) data[i][j][k] = clip;&lt;br /&gt;
                    else if (trace &amp;lt; -clip) data[i][j][k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
        //Write our data out, using the same header values to the file&lt;br /&gt;
        //located at: output.&lt;br /&gt;
         Writer.writeRSF(header,data,output);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to read a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;junk.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to write a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
                &lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;test.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;test2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to create a dataset from scratch from within Java, then you can create an array of data, modify the values, create a header, and then write it out to rsf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                int n1 = 20;&lt;br /&gt;
                int n2 = 40;&lt;br /&gt;
                float[][] data = new float[n2][n1]; &lt;br /&gt;
                //The order for dimensions is reversed, because RSF stores them as column-major arrays (see Python API).&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
&lt;br /&gt;
                Header header = new Header();&lt;br /&gt;
                header.setN(1,n1);&lt;br /&gt;
                /* We set the values using the proper RSF number for the dimension, instead of the Java array index.&lt;br /&gt;
                   Example:  RSF Dimension 1, corresponds to array index 0 in Java.&lt;br /&gt;
                             However, we set the values using index 1.  The mapping is handled behind the scenes.&lt;br /&gt;
                 */&lt;br /&gt;
                header.setN(2,n2); &lt;br /&gt;
                header.setDelta(1,0.0);&lt;br /&gt;
                header.setLabel(1,&amp;quot;time&amp;quot;);&lt;br /&gt;
                header.setUnits(1,&amp;quot;s&amp;quot;);&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;junk2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Package_overview&amp;diff=2462</id>
		<title>Package overview</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Package_overview&amp;diff=2462"/>
		<updated>2013-02-22T01:29:32Z</updated>

		<summary type="html">&lt;p&gt;Nick: Reverted edits by NanetteWashington1968 (talk) to last revision by Ediazpantin&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_5127720_XS.jpg|right|]]&lt;br /&gt;
&lt;br /&gt;
The mission of the Madagascar project is to provide a &#039;&#039;&#039;shared research environment&#039;&#039;&#039; for computational data analysis in geophysics and related fields.&lt;br /&gt;
&lt;br /&gt;
The Madagascar environment consists of:&lt;br /&gt;
# Standalone programs for out-of-core data analysis;&lt;br /&gt;
# Standalone programs for geophysical data processing and imaging;&lt;br /&gt;
# A development kit for C, C++, Java, Fortran-77, Fortran-90, Python, Matlab, and Octave;&lt;br /&gt;
# A framework for reproducible numerical experiments, based on [http://www.scons.org/ SCons];&lt;br /&gt;
# A framework for scientific publications, based on [http://www.scons.org/ SCons] and [http://en.wikipedia.org/wiki/LaTeX LaTeX];&lt;br /&gt;
# A collection of reproducible scientific articles also used as usage examples and regression tests for the standalone programs;&lt;br /&gt;
# A collection of datasets used as input to reproducible numerical experiments.&lt;br /&gt;
&lt;br /&gt;
This guide serves as a brief introduction of different components and shows how they all fit together.&lt;br /&gt;
&lt;br /&gt;
==How to obtain Madagascar==&lt;br /&gt;
&lt;br /&gt;
See [[Download|download]] and [[Installation | installation instructions]]. Madagascar runs on Unix/Linux platforms, including MacOS X and Unix emulations under Miscrosoft Windows. Its installation requires, at a minimum, a working C compiler and Python. &lt;br /&gt;
&lt;br /&gt;
==How to find your way around Madagascar==&lt;br /&gt;
&lt;br /&gt;
Start by checking the [[Reproducible_Documents|list of reproducible papers]]. If any of these papers looks close to your interests, follow the links until you find a figure with a &amp;quot;wrench&amp;quot; button under it [[Image:configure.png]]. Click on the wrench, and it will open a computational recipe used for generating the figure (the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file). &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
Flow(&#039;rose&#039;,None,&lt;br /&gt;
     &#039;&#039;&#039;&lt;br /&gt;
     math n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 &lt;br /&gt;
     output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; |&lt;br /&gt;
     rtoc |&lt;br /&gt;
     math output=&amp;quot;input*exp(I*x1)&amp;quot;&lt;br /&gt;
     &#039;&#039;&#039;)&lt;br /&gt;
Result(&#039;rose&#039;,&lt;br /&gt;
       &#039;graph title=Rose screenratio=1 wantaxis=n&#039;)&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
You can copy this recipe to your computer or simply find it already existing in the &amp;quot;book&amp;quot; subtree under the Madagascar source directory. For example, the recipe at http://www.reproducibility.org/RSF/book/rsf/rsf/sfmath.html also exists in the file &amp;lt;tt&amp;gt;RSFSRC/book/rsf/rsf/sfmath/SConstruct&amp;lt;/tt&amp;gt;. After copying or locating the appropriate &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file,&lt;br /&gt;
run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
on the command line to generate all the figures in the selected project and to display them on your screen. For example, try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cd RSFSRC/book/rsf/rsf/sfmath&lt;br /&gt;
bash$ scons view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;bash$&amp;lt;/tt&amp;gt; stands for the Unix prompt and &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; stands for the Madagascar source directory. The output should look like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
/RSFROOT/bin/sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; | /RSFROOT/bin/sfrtoc | &lt;br /&gt;
/RSFROOT/bin/sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt; rose.rsf /RSFROOT/bin/sfgraph title=Rose screenratio=1 wantaxis=n &amp;gt; Fig/rose.vpl&lt;br /&gt;
/RSFROOT/bin/sfpen Fig/rose.vpl&lt;br /&gt;
scons: done building targets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
with a picture appearing on your screen.&lt;br /&gt;
[[Image:rose.png|frame|center]]&lt;br /&gt;
If there are several figures in the recipe, you can run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons figurename.view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(e.g. &amp;lt;tt&amp;gt;scons rose.view&amp;lt;/tt&amp;gt;) to display individual figures. To remove all files that &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt; generated, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -c view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you want to know in advance what commands will be executed to generate the figures, try&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -n view&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can output this command to a file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scons -n -Q view &amp;gt; script.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and use &amp;lt;tt&amp;gt;script.sh&amp;lt;/tt&amp;gt; as a shell script. If you are to make modifications to the data processing recipe (changing parameters or trying new data), working with SCons is more powerful and convenient than running shell scripts.&lt;br /&gt;
&lt;br /&gt;
A computational recipe puts together individual commands through Unix pipes and SCons rules. These commands act like Lego blocks for creating complex data analysis constructions. In the example above, three &amp;quot;blocks&amp;quot; are used: &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt;. To find out what a particular command is doing, you can follow the links from the bottom of the web page http://www.reproducibility.org/RSF/book/rsf/rsf/sfmath.html&lt;br /&gt;
Alternatively, run the command without arguments on the command line. Running&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfrtoc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
produces something like&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NAME&lt;br /&gt;
        sfrtoc&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
        Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
SYNOPSIS&lt;br /&gt;
        sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
COMMENTS   &lt;br /&gt;
        See also: sfcmplx&lt;br /&gt;
USED IN&lt;br /&gt;
        bei/ft1/plane4&lt;br /&gt;
        bei/ft1/autocor&lt;br /&gt;
        bei/ft1/brad&lt;br /&gt;
        [...]&lt;br /&gt;
SOURCE&lt;br /&gt;
        user/main/rtoc.c&lt;br /&gt;
DOCUMENTATION&lt;br /&gt;
        http://reproducibility.org/wiki/Guide_to_madagascar_programs#sfrtoc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;DOCUMENTATION&amp;lt;/b&amp;gt; section provides a link to a more detailed documentation on the web. The most useful part is the &amp;lt;b&amp;gt;USED IN&amp;lt;/b&amp;gt; section, which points to more examples of using the program. As an exercise, change directory to &amp;lt;tt&amp;gt;RSFSRC/book/bei/ft1/plane4&amp;lt;/tt&amp;gt; or any other example directory, examine the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file, and run &amp;lt;tt&amp;gt;scons view&amp;lt;/tt&amp;gt;. Alternatively, look at http://www.reproducibility.org/RSF/book/bei/ft1/plane4.html&lt;br /&gt;
&lt;br /&gt;
Want to find a program by keywords? Try &amp;lt;tt&amp;gt;sfdoc -k&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdoc -k complex&lt;br /&gt;
sfsort: Sort a float/complex vector by absolute values.&lt;br /&gt;
sfrtoc: Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
sfjacobi2: Find eigenvalues of a general complex matrix by Jacobi-like iteration. &lt;br /&gt;
sfboolcmp: Element-wise boolean comparison of values. For int/float/complex data-sets.&lt;br /&gt;
sfcmatmult: Simple matrix multiplication for complex matrices &lt;br /&gt;
sfimag: Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
sfthr: Threshold float/complex inputs given a constant/varying threshold level.&lt;br /&gt;
sfcpef: 1-D prediction-error filter estimation from complex data &lt;br /&gt;
sfroots: Find roots of a complex polynomial. &lt;br /&gt;
sfreal: Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
sfcmplx: Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
sfsin: Simple operations with complex sinusoids &lt;br /&gt;
sfcdottest: Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
sfcconjgrad: Generic conjugate-gradient solver for linear inversion with complex data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Individual components of the Madagascar environment are described in more details below.&lt;br /&gt;
&lt;br /&gt;
==Madagascar components==&lt;br /&gt;
&lt;br /&gt;
===Standalone programs===&lt;br /&gt;
The list of all standalone programs is available [http://www.reproducibility.org/RSF/ online]. Most programs act as filters on input data and can be chained through Unix pipes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 &amp;gt; data2.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This approach follows the Unix philosophy, as formulated by Doug McIlroy, the inventor of Unix pipes (Salus, 1994&amp;lt;ref&amp;gt;Salus, P. H.,  1994, A quarter-century of Unix: Addison-Wesley.&amp;lt;/ref&amp;gt;):   &lt;br /&gt;
#Write programs that do one thing and do it well.  &lt;br /&gt;
#Write programs to work together.  &lt;br /&gt;
#Write programs to handle text streams, because that is a universal interface. &lt;br /&gt;
&lt;br /&gt;
Following the Unix convention, programs have brief &amp;lt;tt&amp;gt;man&amp;lt;/tt&amp;gt; pages, which explain the program purpose and parameters. You can access this documentation by running a program without parameters. To search for a program by a keyword, use &amp;lt;tt&amp;gt;sfdoc -k &amp;lt;keyword&amp;gt;&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The [[guide to madagascar programs]] provides more detailed documentation for selected programs while the [[task-centric program list]] attempts to categorize them. You can see the programs in actual use in the [[Reproducible Documents]].&lt;br /&gt;
&lt;br /&gt;
===Data format===&lt;br /&gt;
&lt;br /&gt;
For data, Madagascar uses the [[Guide to RSF file format| Regularly Sampled Format]] (RSF), which is based on the concept of hypercubes (n-D arrays, or regularly sampled functions of several variables), much like the SEPlib (its closest relative), DDS, or the regularly-sampled version of the Javaseis format (SVF). Up to 9 dimensions are supported. For 1D it is conceptually analogous to a time series, for 2D to a raster image, and for 3D to a [http://en.wikipedia.org/wiki/Voxel voxel volume].  The format (actually a [http://en.wikipedia.org/wiki/Meta meta]format) makes use of a ASCII file with metadata (information about the data), including a pointer (&amp;lt;tt&amp;gt;in=&amp;lt;/tt&amp;gt; parameter) to the location of the file with the actual data values. Irregularly sampled data are currently handled as a pair of datasets, one containing data and the second containing the corresponding irregular geometry information. Programs for conversion to and from other formats such as SEG-Y and SU are provided. &lt;br /&gt;
&lt;br /&gt;
For graphics, Madagascar currently uses the Vplot vector graphics format. Converters to other graphics formats (Postscript, PNG, GIF, JPEG) are also provided.&lt;br /&gt;
&lt;br /&gt;
===Reproducible documents===&lt;br /&gt;
&lt;br /&gt;
A reproducible document consists of LaTeX source combined with SCons rules required to fully build the documents. These rules are expressed in terms of SCons extensions that are provided as part of Madagascar. &lt;br /&gt;
&lt;br /&gt;
This is the key to the reproducibility aspect of Madagascar. An introduction to reproducible Madagascar documents is at [[Reproducible_computational_experiments_using_SCons]] .&lt;br /&gt;
&lt;br /&gt;
===Vplot graphics===&lt;br /&gt;
&lt;br /&gt;
In contrast to most other Madagascar Components, graphics components produce Vplot data as output.&lt;br /&gt;
&lt;br /&gt;
Vplot is a device independent graphics format that allows both vector and raster elements (as such, &lt;br /&gt;
it is comparable to Postscript). Vplot files are interpreted by a number of output devices. Its typical usage is for a visual display in X-windows. A list of them is [[Guide to madagascar programs#Plotting programs | provided on the wiki]].&lt;br /&gt;
&lt;br /&gt;
Here is an example of a Madagascar pipe. In this case it takes a subsection of a file, low-pass &lt;br /&gt;
filters it, and saves the result&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 &amp;gt; data2.rsf &lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this more elaborate case, the final output is passed to a graphics program and plotted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; data.rsf sfwindow n1=100 | sfbandpass fhi=60 | sfcontour | xtpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More extensive examples are seen in [[Guide to madagascar programs]] . The novice reader should probably read the material below before proceeding to that page.&lt;br /&gt;
&lt;br /&gt;
===Reproducibility and Project Management===&lt;br /&gt;
&lt;br /&gt;
Madagascar uses and extends [http://www.scons.org/ SCons], an open-source &lt;br /&gt;
software construction package, to document and maintain data processing flows. Documented projects become &lt;br /&gt;
computational recipes that can be easily exchanged among Madagascar users. &lt;br /&gt;
&lt;br /&gt;
SCons is a rule-based package in Python typically used as a build system analogous to &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;. Familiarity with any build system will&lt;br /&gt;
be helpful in understanding SCons. SCons statements, as python statements, are invoked in the sequence they are &lt;br /&gt;
written, but as such they only define rules. The rules are invoked in accordance with a dependency graph which&lt;br /&gt;
SCons builds based on those rules. Components regarded as &amp;quot;up-to-date&amp;quot; are not rebuilt. &lt;br /&gt;
&lt;br /&gt;
SCons allows for user-contributed Builders (meta-rule categories) and Madagascar uses this capability extensively. &lt;br /&gt;
The idea is that building an output file based on a workflow chain is very much analogous to building a &lt;br /&gt;
software package based on a software tool chain. The calculation is seen simply as a build with dependencies. &lt;br /&gt;
This is a considerable benefit in developing alternative workflows using a given dataset. The system &lt;br /&gt;
maintains an awareness of already completed calculations. Without user intervention, redundant calculations &lt;br /&gt;
are avoided.&lt;br /&gt;
&lt;br /&gt;
Madagascar calculations are thus expressed as SCons scripts (&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files). SCons extensions follow SCons conventions in beginning &lt;br /&gt;
with an uppercase letter. The most common Madagascar extensions are &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Result()&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;End()&amp;lt;/tt&amp;gt;. A &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; invocation wraps Madagascar computational components. &amp;lt;tt&amp;gt;Result()&amp;lt;/tt&amp;gt; is a version of &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; with a graphical output. Finally an&lt;br /&gt;
End() actually invokes the default rules for multiple results. &lt;br /&gt;
&lt;br /&gt;
Finally, Madagascar enables a collection of reproducible documents, organized in living books. Each &lt;br /&gt;
reproducible book contains a collection of Madagascar recipes (&amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files) used to generate book figures. The recipes &lt;br /&gt;
cover a variety of data processing and imaging tasks described in the books. Figures and recipes serve &lt;br /&gt;
dual purpose with respect to Madagascar maintenance. They provide demos for introducing new users to the &lt;br /&gt;
functionality of the package and, at the same time, [[Automatic Testing|regression tests]] for assuring the system stability &lt;br /&gt;
under change.&lt;br /&gt;
&lt;br /&gt;
==Madagascar Trivia==&lt;br /&gt;
&lt;br /&gt;
===Why the Name &amp;quot;Madagascar&amp;quot;?===&lt;br /&gt;
&lt;br /&gt;
[http://www.reproducibility.org/rsflog/index.php?/archives/67-Madagascar.html Whimsy, really]. It seems easier to remember than the previous name &amp;quot;RSF&amp;quot;, and it provides us interesting [http://www.reproducibility.org/rsflog/index.php?/archives/178-Ahay!.html mascots].&lt;br /&gt;
&lt;br /&gt;
===License===&lt;br /&gt;
&lt;br /&gt;
The Madagascar package is released in an open-source form under the standard [http://www.gnu.org/copyleft/gpl.html GNU GPL] license. In simple &lt;br /&gt;
words, there are no restrictions on the use of the software (including copying, modifying, selling, etc.) &lt;br /&gt;
However, there are restrictions on the software redistribution intended to prevent the package from losing &lt;br /&gt;
its open-source status. Users are encouraged to [[Contributing new programs to Madagascar|submit their modifications]] back to the original distribution for the benefit of the whole [[Package_overview#Community|community]].&lt;br /&gt;
&lt;br /&gt;
===Community===&lt;br /&gt;
&lt;br /&gt;
Madagascar seeks to be an open and active community. Mailing lists are maintained, and annual meetings take place. See &lt;br /&gt;
* [[Conferences]]&lt;br /&gt;
* [http://www.ahay.org/rsflog Development blog]&lt;br /&gt;
* [https://lists.sourceforge.net/lists/listinfo/rsf-user RSF-user mailing list] &lt;br /&gt;
* [https://lists.sourceforge.net/lists/listinfo/rsf-devel RSF-devel mailing list] &lt;br /&gt;
Your participation is welcome.&lt;br /&gt;
&lt;br /&gt;
===History=== &lt;br /&gt;
&lt;br /&gt;
Madagascar was first publicly presented at the [[Conferences#Vienna_2006_.28EAGE.29|EAGE Workshop]] in Vienna in June 2006. The work on the package (previously named RSF) was started by Sergey Fomel in 2003. Since then, many people have contributed to it. See [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/AUTHORS.txt?view=markup AUTHORS.txt] for an incomplete list.&lt;br /&gt;
&lt;br /&gt;
While being written mostly from scratch, Madagascar borrows ideas from the design of [http://sepwww.stanford.ed/doku.php?id=sep:software:seplib SEPlib], a package maintained by Bob Clapp at the Stanford Exploration Project (SEP). Generations of SEP students and researchers contributed to SEPlib. Most important contributions came from Rob Clayton, Jon Claerbout, Dave Hale, Stew Levin, Rick Ottolini, Joe Dellinger, Steve Cole, Dave Nichols, Martin Karrenbach, Biondo Biondi, and Bob Clapp.&lt;br /&gt;
&lt;br /&gt;
Madagascar also borrows ideas from [http://timna.mines.edu/cwpcodes/ Seismic Unix] (SU), an open-source package maintained by John Stockwell at the Center for Wave Phenomena (CWP) at the Colorado School of Mines (Stockwell, 1997&amp;lt;ref&amp;gt;Stockwell, J. W.,  1997, Free software in education: A case study of CWP/SU: Seismic Unix: The Leading Edge, &#039;&#039;&#039;16&#039;&#039;&#039;, 1045--1049.&amp;lt;/ref&amp;gt;;Stockwell, 1999&amp;lt;ref&amp;gt;--------, 1999, The CWP/SU: Seismic Un*x package: Computers and  Geosciences, &#039;&#039;&#039;25&#039;&#039;&#039;, 415--419.&amp;lt;/ref&amp;gt;). Main contributors to SU included Einar Kjartansson, Shuki Ronen, Jack Cohen, Chris Liner, Dave Hale, and John Stockwell. SU adopted an open-source BSD-style license starting with release 40 (April 10, 2007).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=2436</id>
		<title>Guide to madagascar programs</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=2436"/>
		<updated>2012-12-07T03:58:43Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* sfmath */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/prog.tex?view=markup book/rsf/rsf/prog.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide introduces some of the most used &amp;lt;tt&amp;gt;madagascar&amp;lt;/tt&amp;gt; programs and illustrates their usage with examples.&lt;br /&gt;
=Main programs=&lt;br /&gt;
The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/ system/main] in the Madagascar distribution. The &amp;quot;main&amp;quot; programs perform general-purpose operations on RSF hypercubes regardless of the data dimensionality or physical dimensions.&lt;br /&gt;
&lt;br /&gt;
==sfadd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add, multiply, or divide  RSF datasets.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfadd &amp;gt; out.rsf scale= add= sqrt= abs= log= exp= mode= [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | The various operations, if selected, occur in the following order:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;(1) Take absolute value, abs=&amp;lt;br&amp;gt;(2) Add a scalar, add=&amp;lt;br&amp;gt;(3) Take the natural logarithm, log=&amp;lt;br&amp;gt;(4) Take the square root, sqrt=&amp;lt;br&amp;gt;(5) Multiply by a scalar, scale=&amp;lt;br&amp;gt;(6) Compute the base-e exponential, exp=&amp;lt;br&amp;gt;(7) Add, multiply, or divide the data sets, mode=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfadd operates on integer, float, or complex data, but all the input&amp;lt;br&amp;gt;and output files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfadd is sfmath, which is more versatile, but may be&amp;lt;br&amp;gt;less efficient.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;abs=&#039;&#039;&#039; ||   || 	If true take absolute value  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;add=&#039;&#039;&#039; ||   || 	Scalar values to add to each dataset  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;exp=&#039;&#039;&#039; ||   || 	If true compute exponential  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;log=&#039;&#039;&#039; ||   || 	If true take logarithm  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mode=&#039;&#039;&#039; ||   || 	&#039;a&#039; means add (default), &amp;lt;br&amp;gt;       &#039;p&#039; or &#039;m&#039; means multiply, &amp;lt;br&amp;gt;       &#039;d&#039; means divide&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;scale=&#039;&#039;&#039; ||   || 	Scalar values to multiply each dataset with  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;sqrt=&#039;&#039;&#039; ||   || 	If true take square root  [nin]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfadd&amp;lt;/tt&amp;gt; is useful for combining (adding, dividing, or&lt;br /&gt;
multiplying) several datasets. What if you want to subtract two&lt;br /&gt;
datasets? Easy. Use the &amp;lt;tt&amp;gt;scale&amp;lt;/tt&amp;gt; parameter as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd &amp;lt; data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The same task can be accomplished with the more general &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; program:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath one=data1.rsf two=data2.rsf output=&#039;one-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath &amp;lt; data1.rsf two=data2.rsf output=&#039;input-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In both cases, the size and shape of &amp;lt;tt&amp;gt;data1.rsf&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;data2.rsf&amp;lt;/tt&amp;gt; hypercubes should be the same, and a warning&lt;br /&gt;
message is printed out if the the axis sampling parameters (such as&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;) in these files are different.&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/add.c?view=markup system/main/add.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* find number of input files */&lt;br /&gt;
    if (isatty(fileno(stdin))) { &lt;br /&gt;
        /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Collect input files in the &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; array from all command-line&lt;br /&gt;
parameters that don&#039;t contain an &amp;quot;&amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;&amp;quot; sign. The total number&lt;br /&gt;
of input files in &amp;lt;tt&amp;gt;nin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) continue; &lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
    /* nin = no of input files*/&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A helper function &amp;lt;tt&amp;gt;check_compat&amp;lt;/tt&amp;gt; checks the compatibility of&lt;br /&gt;
input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void &lt;br /&gt;
check_compat (sf_datatype type /* data type */, &lt;br /&gt;
	      size_t      nin  /* number of files */, &lt;br /&gt;
	      sf_file*    in   /* input files [nin] */, &lt;br /&gt;
	      int         dim  /* file dimensionality */, &lt;br /&gt;
	      const int*  n    /* dimensions [dim] */)&lt;br /&gt;
/* Check that the input files are compatible. &lt;br /&gt;
   Issue error for type mismatch or size mismatch.&lt;br /&gt;
   Issue warning for grid parameters mismatch. */&lt;br /&gt;
{&lt;br /&gt;
    int ni, id;&lt;br /&gt;
    size_t i;&lt;br /&gt;
    float d, di, o, oi;&lt;br /&gt;
    char key[3];&lt;br /&gt;
    const float tol=1.e-5; /* tolerance for comparison */&lt;br /&gt;
    &lt;br /&gt;
    for (i=1; i &amp;lt; nin; i++) {&lt;br /&gt;
	if (sf_gettype(in[i]) != type) &lt;br /&gt;
	    sf_error (&amp;quot;type mismatch: need %d&amp;quot;,type);&lt;br /&gt;
	for (id=1; id &amp;lt;= dim; id++) {&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,id);&lt;br /&gt;
	    if (!sf_histint(in[i],key,&amp;amp;ni) || ni != n[id-1])&lt;br /&gt;
		sf_error(&amp;quot;%s mismatch: need %d&amp;quot;,key,n[id-1]);&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;d%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;d)) {&lt;br /&gt;
		if (!sf_histfloat(in[i],key,&amp;amp;di) || &lt;br /&gt;
		    (fabsf(di-d) &amp;gt; tol*fabsf(d)))&lt;br /&gt;
		    sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,d);&lt;br /&gt;
	    } else {&lt;br /&gt;
		d = 1.;&lt;br /&gt;
	    }&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;o%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;o) &amp;amp;&amp;amp; &lt;br /&gt;
		(!sf_histfloat(in[i],key,&amp;amp;oi) || &lt;br /&gt;
		 (fabsf(oi-o) &amp;gt; tol*fabsf(d))))&lt;br /&gt;
		sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,o);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we enter the main loop, where input data are getting read&lt;br /&gt;
buffer by buffer and combined in the total product depending on the&lt;br /&gt;
data type.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nbuf /= sf_esize(in[0]); nsiz &amp;gt; 0; nsiz -= nbuf) {&lt;br /&gt;
	if (nbuf &amp;gt; nsiz) nbuf=nsiz;&lt;br /&gt;
&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    collect = (bool) (j != 0);&lt;br /&gt;
	    switch(type) {&lt;br /&gt;
		case SF_FLOAT:&lt;br /&gt;
		    sf_floatread((float*) bufi,&lt;br /&gt;
				 nbuf,&lt;br /&gt;
				 in[j]);	    &lt;br /&gt;
		    add_float(collect, &lt;br /&gt;
			      nbuf,&lt;br /&gt;
			      (float*) buf,&lt;br /&gt;
			      (const float*) bufi, &lt;br /&gt;
			      cmode, &lt;br /&gt;
			      scale[j], &lt;br /&gt;
			      add[j], &lt;br /&gt;
			      abs_flag[j], &lt;br /&gt;
			      log_flag[j], &lt;br /&gt;
			      sqrt_flag[j], &lt;br /&gt;
			      exp_flag[j]);&lt;br /&gt;
		    break;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data combination program for floating point numbers is&lt;br /&gt;
&amp;lt;tt&amp;gt;add_float&amp;lt;/tt&amp;gt;.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void add_float (bool   collect,    /* if collect */&lt;br /&gt;
		       size_t nbuf,       /* buffer size */&lt;br /&gt;
		       float* buf,        /* output [nbuf] */&lt;br /&gt;
		       const float* bufi, /* input  [nbuf] */  &lt;br /&gt;
		       char   cmode,      /* operation */&lt;br /&gt;
		       float  scale,      /* scale factor */&lt;br /&gt;
		       float  add,        /* add factor */&lt;br /&gt;
		       bool   abs_flag,   /* if abs */&lt;br /&gt;
		       bool   log_flag,   /* if log */&lt;br /&gt;
		       bool   sqrt_flag,  /* if sqrt */&lt;br /&gt;
		       bool   exp_flag    /* if exp */)&lt;br /&gt;
/* Add floating point numbers */&lt;br /&gt;
{&lt;br /&gt;
    size_t j;&lt;br /&gt;
    float f;&lt;br /&gt;
&lt;br /&gt;
    for (j=0; j &amp;lt; nbuf; j++) {&lt;br /&gt;
	f = bufi[j];&lt;br /&gt;
	if (abs_flag)    f = fabsf(f);&lt;br /&gt;
	f += add;&lt;br /&gt;
	if (log_flag)    f = logf(f);&lt;br /&gt;
	if (sqrt_flag)   f = sqrtf(f);&lt;br /&gt;
	if (1. != scale) f *= scale;&lt;br /&gt;
	if (exp_flag)    f = expf(f);&lt;br /&gt;
	if (collect) {&lt;br /&gt;
	    switch (cmode) {&lt;br /&gt;
		case &#039;p&#039;: /* product */&lt;br /&gt;
		case &#039;m&#039;: /* multiply */&lt;br /&gt;
		    buf[j] *= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		case &#039;d&#039;: /* delete */&lt;br /&gt;
		    if (f != 0.) buf[j] /= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		default:  /* add */&lt;br /&gt;
		    buf[j] += f;&lt;br /&gt;
		    break;&lt;br /&gt;
	    }&lt;br /&gt;
	} else {&lt;br /&gt;
	    buf[j] = f;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display dataset attributes.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfattr &amp;lt; in.rsf want=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    &amp;lt;br&amp;gt;Sample output from &amp;quot;sfspike n1=100 | sfbandpass fhi=60 | sfattr&amp;quot;&amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;rms = 0.992354 &amp;lt;br&amp;gt;mean value = 0.987576 &amp;lt;br&amp;gt;2-norm value = 9.92354 &amp;lt;br&amp;gt;variance = 0.00955481 &amp;lt;br&amp;gt;standard deviation = 0.0977487 &amp;lt;br&amp;gt;maximum value = 1.12735 at 97 &amp;lt;br&amp;gt;minimum value = 0.151392 at 100 &amp;lt;br&amp;gt;number of nonzero samples = 100 &amp;lt;br&amp;gt;total number of samples = 100 &amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;rms                = sqrt[ sum(data^2) / n ]&amp;lt;br&amp;gt;mean               = sum(data) / n&amp;lt;br&amp;gt;norm               = sum(abs(data)^lval)^(1/lval)&amp;lt;br&amp;gt;variance           = [ sum(data^2) - n*mean^2 ] / [ n-1 ]&amp;lt;br&amp;gt;standard deviation = sqrt [ variance ]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int &#039;&#039; || &#039;&#039;&#039;lval=2&#039;&#039;&#039; ||   || 	norm option, lval is a non-negative integer, computes the vector lval-norm&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;want=&#039;&#039;&#039; ||   || 	&#039;all&#039;(default),&#039;rms&#039;,&#039;mean&#039;,&#039;norm&#039;,&#039;var&#039;,&#039;std&#039;,&#039;max&#039;,&#039;min&#039;,&#039;nonzero&#039;,&#039;samples&#039;,&#039;short&#039; &lt;br /&gt;
:want=   &#039;rms&#039; displays the root mean square&lt;br /&gt;
:want=   &#039;norm&#039; displays the square norm, otherwise specified by lval.&lt;br /&gt;
:want=   &#039;var&#039; displays the variance&lt;br /&gt;
:want=   &#039;std&#039; displays the standard deviation&lt;br /&gt;
:want=   &#039;nonzero&#039; displays number of nonzero samples&lt;br /&gt;
:want=   &#039;samples&#039; displays total number of samples&lt;br /&gt;
:want=   &#039;short&#039; displays a short one-line version&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt; is a useful diagnostic program. It reports certain&lt;br /&gt;
statistical values for an RSF dataset: RMS (root-mean-square)&lt;br /&gt;
amplitude, mean value, vector norm value, variance, standard deviation,&lt;br /&gt;
maximum and minimum values, number of nonzero samples, and the total&lt;br /&gt;
number of samples.&lt;br /&gt;
If we denote data values as &amp;lt;math&amp;gt;d_i&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;i=0,1,2,\ldots,n&amp;lt;/math&amp;gt;, then the RMS&lt;br /&gt;
value is &amp;lt;math&amp;gt;\sqrt{\frac{1}{n}\,\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the mean&lt;br /&gt;
value is &amp;lt;math&amp;gt;\frac{1}{n}\,\sum\limits_{i=0}^n d_i&amp;lt;/math&amp;gt;, the &amp;lt;math&amp;gt;L_2&amp;lt;/math&amp;gt;-norm value&lt;br /&gt;
is &amp;lt;math&amp;gt;\sqrt{\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the variance is&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{n-1}\,\left[\sum\limits_{i=0}^n d_i^2 - \frac{1}{n}\left(\sum\limits_{i=0}^n d_i\right)^2\right]&amp;lt;/math&amp;gt;, and the standard&lt;br /&gt;
deviation is the square root of the variance. Using &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;&lt;br /&gt;
is a quick way to see the distribution of data values and check it for anomalies.&lt;br /&gt;
&lt;br /&gt;
The output can be parsed using utilities such as &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt;, to extract only a numeric value for feeding it as a parameter value into a command line interface. Notice the backticks in the example below:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfgrey &amp;lt;vel.rsf allpos=y bias=`sfattr &amp;lt;vel.rsf want=min | awk &#039;{print $4}&#039;` | sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/attr.c?view=markup system/main/attr.c]====&lt;br /&gt;
&lt;br /&gt;
Computations start by finding the input data (&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;) size&lt;br /&gt;
(&amp;lt;tt&amp;gt;nsiz&amp;lt;/tt&amp;gt;) and dimensions (&amp;lt;tt&amp;gt;dim&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    dim = (size_t) sf_filedims (in,n);&lt;br /&gt;
    for (nsiz=1, i=0; i &amp;lt; dim; i++) {&lt;br /&gt;
	nsiz *= n[i];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the main loop, we read the input data buffer by buffer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft=nsiz; nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (bufsiz &amp;lt; nleft)? bufsiz: nleft;&lt;br /&gt;
	switch (type) {&lt;br /&gt;
	    case SF_FLOAT: &lt;br /&gt;
		sf_floatread((float*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_INT:&lt;br /&gt;
		sf_intread((int*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_COMPLEX:&lt;br /&gt;
		sf_complexread((sf_complex*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_UCHAR:&lt;br /&gt;
		sf_ucharread((unsigned char*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_CHAR:&lt;br /&gt;
	    default:&lt;br /&gt;
		sf_charread(buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data attributes are accumulated in corresponding double-precision&lt;br /&gt;
variables. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	    fsum += f;&lt;br /&gt;
	    fsqr += f*f;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, the attributes are reduced and printed out.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    fmean = fsum/nsiz;&lt;br /&gt;
    if (lval==2)      fnorm = sqrt(fsqr);&lt;br /&gt;
    else if (lval==0) fnorm = nsiz-nzero;&lt;br /&gt;
    else              fnorm = pow(flval,1./lval);&lt;br /&gt;
    frms = sqrt(fsqr/nsiz);&lt;br /&gt;
    if (nsiz &amp;gt; 1) fvar = (fsqr-nsiz*fmean*fmean)/(nsiz-1);&lt;br /&gt;
    else          fvar = 0.0;&lt;br /&gt;
    fstd = sqrt(fvar);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;rms&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;rms = %g \n&amp;quot;,(float) frms);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;mean&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;mean value = %g \n&amp;quot;,(float) fmean);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;norm&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;%d-norm value = %g \n&amp;quot;,lval,(float) fnorm);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;var&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;variance = %g \n&amp;quot;,(float) fvar);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;std&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;standard deviation = %g \n&amp;quot;,(float) fstd);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Concatenate datasets. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcat &amp;gt; out.rsf space= axis=3 nspace=(int) (ni/(20*nin) + 1) [&amp;lt;file0.rsf] file1.rsf file2.rsf ... &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfmerge inserts additional space between merged data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis being merged&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nspace=(int) (ni/(20*nin) + 1)&#039;&#039;&#039; ||   || 	if space=y, number of traces to insert&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;space=&#039;&#039;&#039; ||  [y/n] || 	Insert additional space.&lt;br /&gt;
:y is default for sfmerge, n is default for sfcat&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; concatenate two or more files&lt;br /&gt;
together along a particular axis. It is the same program, only&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; has the default &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;&lt;br /&gt;
has the default &amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcat one.rsf one.rsf axis=1 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=4           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        12 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmerge one.rsf one.rsf axis=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=7           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        14 elements 56 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, an extra empty trace is inserted between the two merged files.&lt;br /&gt;
The axes that are not being merged are checked for consistency:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfcat one.rsf two.rsf &amp;gt; three.rsf&lt;br /&gt;
sfcat: n2 mismatch: need 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cat.c?view=markup system/main/cat.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    in = (sf_file*) sf_alloc ((size_t) argc,sizeof(sf_file));&lt;br /&gt;
&lt;br /&gt;
    if (!sf_stdin()) { /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Everything on the command line that does not contain a &amp;quot;=&amp;quot; sign is&lt;br /&gt;
treated as a file name, and the corresponding file object is added to the list.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) &lt;br /&gt;
	    continue; /* not a file */&lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As explained above, if the &amp;lt;tt&amp;gt;space=&amp;lt;/tt&amp;gt; parameter is not set, it is&lt;br /&gt;
inferred from the program name: &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; corresponds to&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; corresponds to &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if (!sf_getbool(&amp;quot;space&amp;quot;,&amp;amp;space)) {&lt;br /&gt;
	/* Insert additional space.&lt;br /&gt;
	   y is default for sfmerge, n is default for sfcat */&lt;br /&gt;
	prog = sf_getprog();&lt;br /&gt;
	if (NULL != strstr (prog, &amp;quot;merge&amp;quot;)) {&lt;br /&gt;
	    space = true;&lt;br /&gt;
	} else if (NULL != strstr (prog, &amp;quot;cat&amp;quot;)) {&lt;br /&gt;
	    space = false;&lt;br /&gt;
	} else {&lt;br /&gt;
	    sf_warning(&amp;quot;%s is neither merge nor cat,&amp;quot;&lt;br /&gt;
		       &amp;quot; assume merge&amp;quot;,prog);&lt;br /&gt;
	    space = true;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the axis for the merging (from the command line &amp;lt;tt&amp;gt;axis=&amp;lt;/tt&amp;gt;&lt;br /&gt;
argument) and figure out two sizes: &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; for everything after&lt;br /&gt;
the axis and &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; for everything before the axis.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    n1=1;&lt;br /&gt;
    n2=1;&lt;br /&gt;
    for (i=1; i &amp;lt;= dim; i++) {&lt;br /&gt;
	if      (i &amp;lt; axis) n1 *= n[i-1];&lt;br /&gt;
	else if (i &amp;gt; axis) n2 *= n[i-1];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the output, the selected axis will get extended.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* figure out the length of extended axis */&lt;br /&gt;
    ni = 0;&lt;br /&gt;
    for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	ni += naxis[j];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (space) {&lt;br /&gt;
	if (!sf_getint(&amp;quot;nspace&amp;quot;,&amp;amp;nspace)) &lt;br /&gt;
	    nspace = (int) (ni/(20*nin) + 1);&lt;br /&gt;
	/* if space=y, number of traces to insert */ &lt;br /&gt;
	ni += nspace*(nin-1);&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,axis);&lt;br /&gt;
    sf_putint(out,key,(int) ni);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest is simple: loop through the datasets reading and writing the&lt;br /&gt;
data in buffer-size chunks and adding extra empty chunks if&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    for (ni = n1*naxis[j]*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charread (buf,nbuf,in[j]);&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	    if (!space || j == nin-1) continue;&lt;br /&gt;
	    /* Add spaces */&lt;br /&gt;
	    memset(buf,0,BUFSIZ);&lt;br /&gt;
	    for (ni = n1*nspace*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;dat=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mod=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A simple demonstration of the program can be made taking advantage that the complex-to-complex FFT is a linear operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike n1=100 | sfrtoc &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt; spike.rsf sffft axis=1 pad=1 &amp;gt; spike2.rsf&lt;br /&gt;
sfcdottest sffft mod=spike.rsf dat=spike2.rsf axis=1 pad=1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should show values identical down to the last decimal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfcdottest:  L[m]*d=(3.73955,-1.86955)&lt;br /&gt;
sfcdottest: L&#039;[d]*m=(3.73955,-1.86955)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcmplx==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcmplx &amp;gt; cmplx.rsf real.rsf imag.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | There has to be only two input files specified and no additional parameters.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt; simply creates a complex dataset from its real and&lt;br /&gt;
imaginary parts. The reverse operation can be accomplished with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcmplx one.rsf one.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ sfin cmplx.rsf&lt;br /&gt;
cmplx.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/cmplx.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cmplx.c?view=markup system/main/cmplx.c]====&lt;br /&gt;
The program flow is simple. First, get the names of the input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are real and imaginary files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == real) {&lt;br /&gt;
		real = sf_input (argv[i]);&lt;br /&gt;
	    } else {&lt;br /&gt;
		imag = sf_input (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == imag) {&lt;br /&gt;
	if (NULL == real) sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
	/* if only one input, real is in stdin */&lt;br /&gt;
	imag = real;&lt;br /&gt;
	real = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main part of the program reads the real and imaginary parts buffer by buffer and assembles and writes out the complex input. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft= (size_t) (rsize*resize); nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (BUFSIZ &amp;lt; nleft)? BUFSIZ: nleft;&lt;br /&gt;
	sf_charread(rbuf,nbuf,real);&lt;br /&gt;
	sf_charread(ibuf,nbuf,imag);&lt;br /&gt;
	for (i=0; i &amp;lt; nbuf; i += resize) {&lt;br /&gt;
	    memcpy(cbuf+2*i,       rbuf+i,(size_t) resize);&lt;br /&gt;
	    memcpy(cbuf+2*i+resize,ibuf+i,(size_t) resize);&lt;br /&gt;
	}&lt;br /&gt;
	sf_charwrite(cbuf,2*nbuf,cmplx);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
==sfconjgrad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic conjugate-gradient solver for linear inversion &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfconjgrad &amp;lt; dat.rsf mod=mod.rsf &amp;gt; to.rsf &amp;lt; from.rsf &amp;gt; out.rsf niter=1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=1&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is a generic program for least-squares linear&lt;br /&gt;
inversion with the [http://en.wikipedia.org/wiki/Conjugate_gradient_method conjugate-gradient method]. Suppose you have an&lt;br /&gt;
executable program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the&lt;br /&gt;
standard input and produces an RSF file in the standard output. It may&lt;br /&gt;
take any number of additional parameters but one of them must be&lt;br /&gt;
&amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint&lt;br /&gt;
(&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.  The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically&lt;br /&gt;
an RSF program but it could be anything (a script, a multiprocessor&lt;br /&gt;
MPI program, etc.) as long as it implements a linear operator&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint. There are no restrictions on the data&lt;br /&gt;
size or shape. You can easily test the adjointness with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; program searches for a&lt;br /&gt;
vector &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; that minimizes the least-square misfit &lt;br /&gt;
&amp;lt;math&amp;gt;\|\mathbf{d - L\,m}\|^2&amp;lt;/math&amp;gt; for the given input data vector &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The pseudocode for &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is given at the end of the [http://www.reproducibility.org/RSF/book/gee/lsq/paper.pdf &amp;quot;Model fitting with least squares&amp;quot; chapter] of &#039;&#039;Imaging Estimation by Example&#039;&#039; by Jon Claerbout, with the earliest form published in [http://sepwww.stanford.edu/data/media/public/oldreports/sep48/48_25.pdf &amp;quot;Conjugate Gradient Tutorial&amp;quot;] (SEP-48, 1986, same author). A simple toy implementation with a small matrix shows that this is algorithm produces the same steps as the algorithm described in equations 45-49 of [http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf &amp;quot;An introduction to the Conjugate Gradient Method Without the Agonizing Pain&amp;quot;] by J.R. Shewchuk, 1994, when the equation &amp;lt;math&amp;gt;A^T A x = A^T b&amp;lt;/math&amp;gt; (in Shewchuk&#039;s notation) is solved. Multiplying with the transpose ensures a correct solution even when matrix A is square but not symmetric, or not square at all. The program [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad] implements this algorithm for the case when inputs are complex.&lt;br /&gt;
&lt;br /&gt;
Here is an example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test to&lt;br /&gt;
check that the adjoint mode works correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=5.28394&lt;br /&gt;
sfdottest: L&#039;[d]*m=5.28394&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your numbers may be different because &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; generates new&lt;br /&gt;
random input on each run.&lt;br /&gt;
Next, let us make some random data with &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfnoise seed=2005 rep=y &amp;lt; vec.rsf &amp;gt; dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and try to invert the filtering operation using &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfconjgrad sfhelicon filt=flt.rsf lag=lag.rsf mod=vec.rsf &amp;lt; dat.rsf &amp;gt; mod.rsf niter=10&lt;br /&gt;
sfconjgrad: iter 1 of 10&lt;br /&gt;
sfconjgrad: grad=3253.65&lt;br /&gt;
sfconjgrad: iter 2 of 10&lt;br /&gt;
sfconjgrad: grad=289.421&lt;br /&gt;
sfconjgrad: iter 3 of 10&lt;br /&gt;
sfconjgrad: grad=92.3481&lt;br /&gt;
sfconjgrad: iter 4 of 10&lt;br /&gt;
sfconjgrad: grad=36.9417&lt;br /&gt;
sfconjgrad: iter 5 of 10&lt;br /&gt;
sfconjgrad: grad=18.7228&lt;br /&gt;
sfconjgrad: iter 6 of 10&lt;br /&gt;
sfconjgrad: grad=11.1794&lt;br /&gt;
sfconjgrad: iter 7 of 10&lt;br /&gt;
sfconjgrad: grad=7.26941&lt;br /&gt;
sfconjgrad: iter 8 of 10&lt;br /&gt;
sfconjgrad: grad=5.15945&lt;br /&gt;
sfconjgrad: iter 9 of 10&lt;br /&gt;
sfconjgrad: grad=4.23055&lt;br /&gt;
sfconjgrad: iter 10 of 10&lt;br /&gt;
sfconjgrad: grad=3.57495&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output shows that, in 10 iterations, the norm of the gradient vector decreases by almost 1000. &lt;br /&gt;
We can check the residual misfit before&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; dat.rsf sfattr want=norm&lt;br /&gt;
norm value = 49.7801&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and after&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfhelicon filt=flt.rsf lag=lag.rsf &amp;lt; mod.rsf | sfadd scale=1,-1 dat.rsf | sfattr want=norm&lt;br /&gt;
norm value = 5.73563&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In 10 iterations, the misfit decreased by an order of magnitude. The&lt;br /&gt;
result can be improved by running the program for more iterations.&lt;br /&gt;
&lt;br /&gt;
An equivalent implementation for complex-valued inputs is [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad]. A simple, lightweight Python implementation can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/user/fomels/conjgrad.py?view=markup $PYTHONPATH/rsf/conjgrad.py].&lt;br /&gt;
&lt;br /&gt;
==sfcp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Copy or move a dataset.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcp in.rsf out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfcp - copy, sfmv - move.&amp;lt;br&amp;gt;Mimics standard Unix commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmv&amp;lt;/tt&amp;gt; command imitate the Unix&lt;br /&gt;
&amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; commands and serve for copying and moving&lt;br /&gt;
RSF files. Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcp one.rsf two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cp.c?view=markup system/main/cp.c]====&lt;br /&gt;
First, we look for the two first command-line arguments that don&#039;t&lt;br /&gt;
have the &amp;quot;=&amp;quot; character in them and consider them as the names of the&lt;br /&gt;
input and the output files.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are in and out files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == in) {&lt;br /&gt;
		infile = argv[i];&lt;br /&gt;
		in = sf_input (infile);&lt;br /&gt;
	    } else {&lt;br /&gt;
		out = sf_output (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == in || NULL == out)&lt;br /&gt;
	sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we use library functions &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_cp&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_rm&amp;lt;/font&amp;gt; to do the actual work.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_cp(in,out);&lt;br /&gt;
    if (NULL != strstr (sf_getprog(),&amp;quot;mv&amp;quot;)) &lt;br /&gt;
	sf_rm(infile,false,false,false);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcut &amp;lt; in.rsf &amp;gt; out.rsf verb=n [j1=1 j2=1 ... f1=0 f2=0 ... n1=n1 n2=n2 ... max1= max2= ... min1= min2= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | jN defines the jump in N-th dimension&amp;lt;br&amp;gt;fN is the window start&amp;lt;br&amp;gt;nN is the window size&amp;lt;br&amp;gt;minN and maxN is the maximum and minimum in N-th dimension&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Reverse of window. &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcut&amp;lt;/tt&amp;gt; command is related to &amp;lt;tt&amp;gt;sfwindow&amp;lt;/tt&amp;gt; and has the same&lt;br /&gt;
set of arguments only instead of extracting the selected window, it fills it&lt;br /&gt;
with zeroes. The size of the input data is preserved. &lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; in.rsf&lt;br /&gt;
bash$ &amp;lt; in.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut n1=2 f1=1 n2=3 f2=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            0            0            1            1&lt;br /&gt;
  15:             1            0            0            1            1&lt;br /&gt;
  20:             1            0            0            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut j1=2 | sfdisfil&lt;br /&gt;
   0:             0            1            0            1            0&lt;br /&gt;
   5:             0            1            0            1            0&lt;br /&gt;
  10:             0            1            0            1            0&lt;br /&gt;
  15:             0            1            0            1            0&lt;br /&gt;
  20:             0            1            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfdd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert between different formats. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdd &amp;lt; in.rsf &amp;gt; out.rsf line=8 form= type= format=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;form=&#039;&#039;&#039; ||   || 	ascii, native, xdr&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Element format (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;line=8&#039;&#039;&#039; ||   || 	Number of numbers per line (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	int, float, complex&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; program is used to change either the form (&amp;lt;tt&amp;gt;ascii&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;native&amp;lt;/tt&amp;gt;) or the type (&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt;) of the input dataset. &lt;br /&gt;
In the example below, we create a plain text (ASCII) file with numbers and&lt;br /&gt;
then use &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; to generate an RSF file in &amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt; form with&lt;br /&gt;
&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt; numbers. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cat test.txt&lt;br /&gt;
1 2 3 4 5 6&lt;br /&gt;
bash$ echo n1=6 data_format=ascii_int in=test.txt &amp;gt; test.rsf&lt;br /&gt;
bash$ sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;test.txt&amp;quot;&lt;br /&gt;
    esize=0 type=int form=ascii&lt;br /&gt;
    n1=6           d1=?           o1=?&lt;br /&gt;
        6 elements&lt;br /&gt;
bash$ sfdd &amp;lt; test.rsf form=xdr type=complex &amp;gt; test2.rsf&lt;br /&gt;
bash$ sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=xdr&lt;br /&gt;
    n1=3           d1=?           o1=?&lt;br /&gt;
        3 elements 24 bytes&lt;br /&gt;
bash$ sfdisfil &amp;lt; test2.rsf&lt;br /&gt;
   0:          1,         2i         3,         4i         5,         6i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To learn more about the RSF data format, consult the [[Guide to RSF file format| guide to RSF format]].&lt;br /&gt;
&lt;br /&gt;
==sfdisfil==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Print out data values.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdisfil &amp;lt; in.rsf number=y col=0 format= header= trailer=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Alternatively, use sfdd and convert to ASCII form.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;col=0&#039;&#039;&#039; ||   || 	Number of columns.&lt;br /&gt;
:The default depends on the data type:&lt;br /&gt;
:10 for int and char,&lt;br /&gt;
:5 for float,&lt;br /&gt;
:3 for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Format for numbers (printf-style).&lt;br /&gt;
:The default depends on the data type:&amp;lt;br&amp;gt;       &amp;quot;%4d &amp;quot; for int and char,&amp;lt;br&amp;gt;       &amp;quot;%13.4g&amp;quot; for float,&amp;lt;br&amp;gt;       &amp;quot;%10.4g,%10.4gi&amp;quot; for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;header=&#039;&#039;&#039; ||   || 	Optional header string to output before data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;number=y&#039;&#039;&#039; ||  [y/n] || 	If number the elements&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;trailer=&#039;&#039;&#039; ||   || 	Optional trailer string to output after data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; program simply dumps the data contents to the standard&lt;br /&gt;
output in a text form. It is used mostly for debugging purposes to quickly&lt;br /&gt;
examine RSF files. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath o1=0 d1=2 n1=12 output=x1 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
  10:            20           22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output format is easily configurable.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil col=6 number=n format=&amp;quot;%5.1f&amp;quot;&lt;br /&gt;
  0.0  2.0  4.0  6.0  8.0 10.0&lt;br /&gt;
 12.0 14.0 16.0 18.0 20.0 22.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Along with &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; provides a simple way to convert&lt;br /&gt;
RSF data to an ASCII form.&lt;br /&gt;
&lt;br /&gt;
==sfdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; is a generic dot-product test program for testing&lt;br /&gt;
linear operators. Suppose there is an executable program&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the standard input and&lt;br /&gt;
produces an RSF file in the standard output. It may take any number of&lt;br /&gt;
additional parameters but one of them must be &amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets&lt;br /&gt;
the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint (&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.&lt;br /&gt;
The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically an RSF program but it could&lt;br /&gt;
be anything (a script, a multiprocessor MPI program, etc.) as long as&lt;br /&gt;
it implements a linear operator &amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}^T&amp;lt;/math&amp;gt;. The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program is testing the equality&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
d^T\,L\,m = m^T\,L^T\,d&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
by using random vectors &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. You can invoke it with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest &amp;lt;prog&amp;gt; [optional aruments] mod=mod.rsf dat=dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;mod.rsf&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;dat.rsf&amp;lt;/tt&amp;gt; are RSF files that&lt;br /&gt;
represent vectors from the model and data spaces. Pay attention to the &lt;br /&gt;
dimension and size of these vectors! If the program does not respond&lt;br /&gt;
for a very long time, it is quite possible that the dimension and size&lt;br /&gt;
of the vectors are inconsistent with the requirement of the program to be&lt;br /&gt;
tested. &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;&lt;br /&gt;
does not create any temporary files and does not have any restrictive&lt;br /&gt;
limitations on the size of the vectors.&lt;br /&gt;
Here is an example. We first setup a vector with 100 elements using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; and then run &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; to test the&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; program. &amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; implements a linear&lt;br /&gt;
operator of causal integration and its adjoint, the anti-causal&lt;br /&gt;
integration.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 &amp;gt; vec.rsf&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1410.2&lt;br /&gt;
sfdottest: L&#039;[d]*m=1410.2&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1165.87&lt;br /&gt;
sfdottest: L&#039;[d]*m=1165.87&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The numbers are different on subsequent runs because of changing&lt;br /&gt;
seed in the random number generator.&lt;br /&gt;
Here is a somewhat more complicated example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now the &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=8.97375&lt;br /&gt;
sfdottest: L&#039;[d]*m=8.97375&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is the same program tested in the inverse filtering mode:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf div=y&lt;br /&gt;
sfdottest:  L[m]*d=15.0222&lt;br /&gt;
sfdottest: L&#039;[d]*m=15.0222&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfget==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Output parameters from the header.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfget &amp;lt; in.rsf parform=y par1 par2 ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;parform=y&#039;&#039;&#039; ||  [y/n] || 	If y, print out parameter=value. If n, print out value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt; program extracts a parameter value from an RSF file. It is&lt;br /&gt;
useful mostly for scripting. Here is, for example, a quick calculation of the&lt;br /&gt;
maximum value on the first axis in an RSF dataset (the output of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;) using the standard Unix &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt; calculator.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ ( sfspike n1=100 | sfget n1 d1 o1; echo &amp;quot;o1+(n1-1)*d1&amp;quot; ) | bc&lt;br /&gt;
.396&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See also &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/get.c?view=markup system/main/get.c]====&lt;br /&gt;
The implementation is trivial. Loop through all command-line parameters that contain &lt;br /&gt;
the &amp;quot;=&amp;quot; character.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i = 1; i &amp;lt; argc; i++) {&lt;br /&gt;
	key = argv[i];&lt;br /&gt;
	if (NULL != strchr(key,&#039;=&#039;)) continue;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the parameter value (as string) and output it as either&lt;br /&gt;
&amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, depending on the&lt;br /&gt;
&amp;lt;tt&amp;gt;parform&amp;lt;/tt&amp;gt; parameter.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	string = sf_histstring(in,key);&lt;br /&gt;
	if (NULL == string) {&lt;br /&gt;
	    sf_warning(&amp;quot;No key %s&amp;quot;,key);&lt;br /&gt;
	} else {&lt;br /&gt;
	    if (parform) printf (&amp;quot;%s=&amp;quot;,key);&lt;br /&gt;
	    printf(&amp;quot;%s\n&amp;quot;,string);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheadercut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadercut mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array of size n2.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; is close to &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; but instead&lt;br /&gt;
of windowing the dataset, it fills the traces specified by the header&lt;br /&gt;
mask with zeroes. The size of the input data is preserved.&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for &lt;br /&gt;
zeroing every other trace in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a mask with alternating ones and zeros using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 mag=1 | sfdd type=int &amp;gt; ones.rsf&lt;br /&gt;
bash$ sfspike n1=5 mag=0 | sfdd type=int &amp;gt; zeros.rsf&lt;br /&gt;
bash$ sfinterleave axis=1 ones.rsf zeros.rsf &amp;gt; mask.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; mask.rsf&lt;br /&gt;
   0:    1    0    1    0    1    0    1    0    1    0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, &amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; zeros the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfheadercut &amp;lt; input.rsf mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; output.rsf &lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             0            0            0            0            0&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             0            0            0            0            0&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfheadersort==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Sort a dataset according to a header key. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadersort &amp;lt; in.rsf &amp;gt; out.rsf head=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;head=&#039;&#039;&#039; ||   || 	header file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is used to sort traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; for randomly shuffling traces in the input&lt;br /&gt;
file. First, let us create an input file with seven traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=7 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with seven header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=7 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:       0.05256      -0.2879       0.1487       0.4097       0.1548&lt;br /&gt;
   5:        0.4501       0.2836&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally, we&lt;br /&gt;
apply &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; to shuffle the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheadersort head=random.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             5            5            5            5            5&lt;br /&gt;
  20:             7            7            7            7            7&lt;br /&gt;
  25:             4            4            4            4            4&lt;br /&gt;
  30:             6            6            6            6            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As expected, the order of traces in the output file corresponds to the&lt;br /&gt;
order of values in the header. Thanks to the separation between&lt;br /&gt;
headers and data, the operation of &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is optimally&lt;br /&gt;
efficient. It first sorts the headers and only then accesses the data,&lt;br /&gt;
reading each data trace only once.&lt;br /&gt;
&lt;br /&gt;
==sfheaderwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderwindow mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array os size n2, windowed is n1xm2,&amp;lt;br&amp;gt;where m2 is the number of nonzero elements in mask.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is used to window traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for randomly&lt;br /&gt;
selecting part of the traces in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with ten header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:     -0.005768      0.02258     -0.04331      -0.4129      -0.3909&lt;br /&gt;
   5:      -0.03582       0.4595      -0.3326        0.498      -0.3517&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally,&lt;br /&gt;
we apply &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; to window the input traces selecting&lt;br /&gt;
only those for which the header is greater than zero.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; random.rsf sfmask min=0 &amp;gt; mask.rsf&lt;br /&gt;
bash$ &amp;lt; mask.rsf sfdisfil&lt;br /&gt;
   0:    0    1    0    0    0    0    1    0    1    0&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheaderwindow mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             7            7            7            7            7&lt;br /&gt;
  10:             9            9            9            9            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, only three traces are selected for the output. Thanks to&lt;br /&gt;
the separation between headers and data, the operation of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is optimally efficient. &lt;br /&gt;
&lt;br /&gt;
==sfin==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display basic information about RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfin info=y check=2. trail=y file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | n1,n2,... are data dimensions&amp;lt;br&amp;gt;o1,o2,... are axis origins&amp;lt;br&amp;gt;d1,d2,... are axis sampling intervals&amp;lt;br&amp;gt;label1,label2,... are axis labels&amp;lt;br&amp;gt;unit1,unit2,... are axis units&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;check=2.&#039;&#039;&#039; ||   || 	Portion of the data (in Mb) to check for zero values.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;info=y&#039;&#039;&#039; ||  [y/n] || 	If n, only display the name of the data file.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trail=y&#039;&#039;&#039; ||  [y/n] || 	If n, skip trailing dimensions of  one&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; is one of the most useful programs for operating with&lt;br /&gt;
RSF files. It produces quick information on the file hypercube&lt;br /&gt;
dimensions and checks the consistency of the associated data file.&lt;br /&gt;
Here is an example. Let us create an RSF file and examine it with &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=20 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=100         d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        2000 elements 8000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; reports the following information:&lt;br /&gt;
  &lt;br /&gt;
*location of the data file (&amp;lt;tt&amp;gt;/tmp/spike.rsf\@&amp;lt;/tt&amp;gt;) &lt;br /&gt;
*element size (4 bytes) &lt;br /&gt;
*element type (floating point) &lt;br /&gt;
*element form (native) &lt;br /&gt;
*hypercube dimensions (100 by 20) &lt;br /&gt;
*axes scale (0.004 and 0.1) &lt;br /&gt;
*axes origin (0 and 0) &lt;br /&gt;
*axes labels &lt;br /&gt;
*axes units &lt;br /&gt;
*total number of elements &lt;br /&gt;
*total number of bytes in the data file &lt;br /&gt;
Suppose that the file got corrupted by a buggy program and reports&lt;br /&gt;
incorrect dimensions. The &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; program should be able to&lt;br /&gt;
catch the discrepancy.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo n2=100 &amp;gt;&amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf &amp;gt; /dev/null&lt;br /&gt;
sfin:           Actually 8000 bytes, 20% of expected.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; also checks the first records in the file for zeros. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=100 k2=99 &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 32768 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The number of bytes to check is adjustable&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike2.rsf check=0.01 &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 16384 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can also output only the location of the data file. This is&lt;br /&gt;
sometimes handy in scripts.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike.rsf spike2.rsf info=n&lt;br /&gt;
/tmp/spike.rsf@ /tmp/spike2.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An alternative is to use &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfget parform=n in &amp;lt; spike.rsf&lt;br /&gt;
/tmp/spike.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To actually eliminate annoying trailing dimensions of length one (not just stop displaying them with &amp;lt;tt&amp;gt;trail=n&amp;lt;/tt&amp;gt;), you may use &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt;. Example for eliminating axis 6:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sed -i &#039;s/n6=1//g&#039; file.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfinterleave==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Combine several datasets by interleaving.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfinterleave &amp;gt; out.rsf axis=3 [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis for interleaving&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt; combines two or more datasets by interleaving them on one&lt;br /&gt;
of the axes. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ sfscale &amp;lt; one.rsf dscale=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; two.rsf&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             2            2            2            2            2&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             2            2            2            2            2&lt;br /&gt;
bash$ sfinterleave one.rsf two.rsf axis=1 | sfdisfil&lt;br /&gt;
   0:             1            2            1            2            1&lt;br /&gt;
   5:             2            1            2            1            2&lt;br /&gt;
  10:             1            2            1            2            1&lt;br /&gt;
  15:             2            1            2            1            2&lt;br /&gt;
  20:             1            2            1            2            1&lt;br /&gt;
  25:             2            1            2            1            2&lt;br /&gt;
  30:             1            2            1            2            1&lt;br /&gt;
  35:             2            1            2            1            2&lt;br /&gt;
  40:             1            2            1            2            1&lt;br /&gt;
  45:             2            1            2            1            2&lt;br /&gt;
bash$ sfinterleave &amp;lt; one.rsf two.rsf axis=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
  25:             2            2            2            2            2&lt;br /&gt;
  30:             1            1            1            1            1&lt;br /&gt;
  35:             2            2            2            2            2&lt;br /&gt;
  40:             1            1            1            1            1&lt;br /&gt;
  45:             2            2            2            2            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmask==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmask &amp;lt; in.rsf &amp;gt; out.rsf min=-FLT_MAX max=+FLT_MAX&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Mask is an integer data with ones and zeros. &amp;lt;br&amp;gt;Ones correspond to input values between min and max.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The output can be used with sfheaderwindow.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=+FLT_MAX&#039;&#039;&#039; ||   || 	maximum header value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=-FLT_MAX&#039;&#039;&#039; ||   || 	minimum header value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmask&amp;lt;/tt&amp;gt; creates an integer output of ones and zeros comparing&lt;br /&gt;
the values of the input data to specified &amp;lt;tt&amp;gt;min=&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;max=&amp;lt;/tt&amp;gt; parameters. It is useful for &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; and&lt;br /&gt;
in many other applications. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 output=&amp;quot;sin(x1)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdisfil&lt;br /&gt;
   0:             0       0.8415       0.9093       0.1411      -0.7568&lt;br /&gt;
   5:       -0.9589      -0.2794        0.657       0.9894       0.4121&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfmask min=-0.5 max=0.5 | sfdisfil&lt;br /&gt;
   0:    1    0    0    1    0    0    1    0    0    1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations on data files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmath &amp;gt; out.rsf n#= d#=(1,1,...) o#=(0,0,...) label#= unit#= type= label= unit= output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    &amp;lt;br&amp;gt;Known functions: &amp;lt;br&amp;gt;cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;exp,  log,  sqrt, abs,&amp;lt;br&amp;gt;erf,  erfc (for float data),&amp;lt;br&amp;gt;arg,  conj, real, imag (for complex data).&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfmath will work on float or complex data, but all the input and output&amp;lt;br&amp;gt;files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfmath is sfadd, which may be more efficient, but is&amp;lt;br&amp;gt;less versatile.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Examples:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfmath x=file1.rsf y=file2.rsf power=file3.rsf output=&#039;sin((x+2*y)^power)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath &amp;lt; file1.rsf tau=file2.rsf output=&#039;exp(tau*input)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath n1=100 type=complex output=&amp;quot;exp(I*x1)&amp;quot; &amp;gt; out.rsf&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Arguments which are not treated as variables in mathematical expressions:&amp;lt;br&amp;gt;datapath=, type=, out=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(1,1,...)&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	data label&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;largeint&#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o#=(0,0,...)&#039;&#039;&#039; ||   || 	origin on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Mathematical description of the output&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	output data type [float,complex]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	data unit&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; is a versatile program for mathematical operations&lt;br /&gt;
with RSF files. It can operate with several input files, all of the&lt;br /&gt;
same dimensions and data type. The data type can be real (floating&lt;br /&gt;
point) or complex. Here is an example that demonstrates several&lt;br /&gt;
features of &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 \&lt;br /&gt;
output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; &amp;gt; rad.rsf&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfrtoc | sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
bash$ &amp;lt; rose.rsf sfgraph title=Rose screenratio=1 wantaxis=n | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first line creates a 2-D dataset that consists of 40 traces 629&lt;br /&gt;
samples each. The values of the data are computed with the formula&lt;br /&gt;
&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
coordinate on the first axis, and &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt; is the coordinate of the&lt;br /&gt;
second axis. In the second line, we convert the data from real to&lt;br /&gt;
complex using &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; and produce a complex dataset using&lt;br /&gt;
formula &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;input*exp(I*x1)&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
input file. Finally, we plot the complex data as a collection of&lt;br /&gt;
parametric curves using &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt; and display the result using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpen&amp;lt;/tt&amp;gt;.  The plot appearing on your screen should look similar&lt;br /&gt;
to the figure.&lt;br /&gt;
[[Image:rose.png|frame|center|This figure was created with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
One possible alternative to the second line above is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfmath output=x1 &amp;gt; ang.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*cos(a)&amp;quot; &amp;gt; cos.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*sin(a)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ sfcmplx cos.rsf sin.rsf &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we refer to input files by names (&amp;lt;tt&amp;gt;r&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;) and combine the names in a formula.&lt;br /&gt;
&lt;br /&gt;
Functions can be nested and combined, and variable names, as well as the the &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; keyword may be combined with the axes keywords &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt;, etc. Here is an example that shifts a wavelet -0.4s to t=0, computes the frequency-domain complex square root (equivalent to the convolutional square root in time), and shifts the result back to t=0.4s:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
pi=3.14159265&lt;br /&gt;
tshift=0.4&lt;br /&gt;
&lt;br /&gt;
sfspike n1=256 k1=101 |\&lt;br /&gt;
sfbandpass flo=4 fhi=30 |\&lt;br /&gt;
sffft1 opt=n sym=y |\&lt;br /&gt;
sfmath output=&amp;quot;sqrt(input*exp(2*$pi*$tshift*x1*I))*exp(-2*$pi*$tshift*x1*I)&amp;quot; |\&lt;br /&gt;
sffft1 opt=n sym=y inv=y |\&lt;br /&gt;
sfgraph |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfpad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Pad a dataset with zeros.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpad &amp;lt; in.rsf &amp;gt; out.rsf beg#=0 end#=0 n#=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;   n#out is equivalent to n#, both of them overwrite end#.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;beg#=0&#039;&#039;&#039; ||   || 	the number of zeros to add before the beginning of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;end#=0&#039;&#039;&#039; ||   || 	the number of zeros to add after the end of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	the output length of #-th axis - padding at the end&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpad&amp;lt;/tt&amp;gt; increases the dimensions of the input dataset by padding&lt;br /&gt;
the data with zeroes. Here are some simple examples.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad n2=5 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=2 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=1 end2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfwindow n1=3 | sfpad n1=5 n2=5 beg1=1 beg2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            1            1            1            0&lt;br /&gt;
  10:             0            1            1            1            0&lt;br /&gt;
  15:             0            1            1            1            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can use &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; to pad data with values other than zeroes.&lt;br /&gt;
&lt;br /&gt;
==sfput==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Input parameters into a header. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfput &amp;lt; in.rsf &amp;gt; out.rsf [parameter=value list]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is a very simple program. It simply appends parameters&lt;br /&gt;
from the command line to the output RSF file. One can achieve similar&lt;br /&gt;
results with editing the file by hand or with standard Unix utilities like&lt;br /&gt;
&amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is sometimes more&lt;br /&gt;
convenient because it handles input/output operations similarly to&lt;br /&gt;
other Madagascar programs.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash$ sfput &amp;lt; spike.rsf d1=25 label1=Depth unit1=m &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf&lt;br /&gt;
spike2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=25          o1=0          label1=&amp;quot;Depth&amp;quot; unit1=&amp;quot;m&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreal==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreal &amp;lt; cmplx.rsf &amp;gt; real.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; extracts the real part of a complex type dataset. The&lt;br /&gt;
imaginary part can be extracted with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;, an the real&lt;br /&gt;
and imaginary part can be combined together with &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Here is a simple example. Let us first create a complex dataset &lt;br /&gt;
with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 type=complex output=&amp;quot;(2+I)*x1&amp;quot; &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ fdisfil &amp;lt; cmplx.rsf&lt;br /&gt;
   0:          0,         0i         2,         1i         4,         2i&lt;br /&gt;
   3:          6,         3i         8,         4i        10,         5i&lt;br /&gt;
   6:         12,         6i        14,         7i        16,         8i&lt;br /&gt;
   9:         18,         9i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the real part with &amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfreal &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the imaginary part with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfimag &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             5            6            7            8            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreverse==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Reverse one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreverse &amp;lt; in.rsf &amp;gt; out.rsf which=-1 verb=false memsize=sf_memsize() opt=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;opt=&#039;&#039;&#039; ||   || 	If y, change o and d parameters on the reversed axis;&lt;br /&gt;
:if i, don&#039;t change o and d&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;which=-1&#039;&#039;&#039; ||   || 	Which axis to reverse.&lt;br /&gt;
:To reverse a given axis, start with 0,&lt;br /&gt;
:add 1 to number to reverse n1 dimension,&lt;br /&gt;
:add 2 to number to reverse n2 dimension,&lt;br /&gt;
:add 4 to number to reverse n3 dimension, etc.&lt;br /&gt;
:Thus, which=7 would reverse the first three dimensions,&lt;br /&gt;
:which=5 just n1 and n3, etc.&lt;br /&gt;
:which=0 will just pass the input on through unchanged.&lt;br /&gt;
|}&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfreverse&amp;lt;/tt&amp;gt;. First, let us create a&lt;br /&gt;
2-D dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the first axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfdisfil&lt;br /&gt;
   0:             4            3            2            1            0&lt;br /&gt;
   5:             5            4            3            2            1&lt;br /&gt;
  10:             6            5            4            3            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=2 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=3 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;which=&amp;lt;/tt&amp;gt; parameter controls the axes that are&lt;br /&gt;
being reversed by encoding them into one number.&lt;br /&gt;
When an axis is reversed, what happens with its axis origin and&lt;br /&gt;
sampling parameters? This behavior is controlled by &amp;lt;tt&amp;gt;opt=&amp;lt;/tt&amp;gt;. In&lt;br /&gt;
our example,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfget n1 o1 d1&lt;br /&gt;
n1=5&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfget o1 d1&lt;br /&gt;
o1=4&lt;br /&gt;
d1=-1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The default behavior (equivalent to &amp;lt;tt&amp;gt;opt=y&amp;lt;/tt&amp;gt;) puts the origin&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; at the end of the axis and reverses the sampling parameter&lt;br /&gt;
&amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;.  Using &amp;lt;tt&amp;gt;opt=n&amp;lt;/tt&amp;gt; preserves the sampling but reverses&lt;br /&gt;
the origin.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=n | sfget o1 d1&lt;br /&gt;
o1=-4&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Using &amp;lt;tt&amp;gt;opt=i&amp;lt;/tt&amp;gt; preserves both the sampling and the origin while&lt;br /&gt;
reversing the axis.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=i | sfget o1 d1&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
One of the three possible behaviors may be desirable depending on the&lt;br /&gt;
application.&lt;br /&gt;
&lt;br /&gt;
==sfrm==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Remove RSF files together with their data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrm file1.rsf [file2.rsf ...] [-i] [-v] [-f] &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Mimics the standard Unix rm command.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfmv, sfcp.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; is a program for removing RSF files. Its arguments mimic&lt;br /&gt;
the arguments of the standard Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt; utility: &amp;lt;tt&amp;gt;-v&amp;lt;/tt&amp;gt;&lt;br /&gt;
for verbosity, &amp;lt;tt&amp;gt;-i&amp;lt;/tt&amp;gt; for interactive inquiry, &amp;lt;tt&amp;gt;-f&amp;lt;/tt&amp;gt; for&lt;br /&gt;
force removal of suspicious files. Unlike the Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; removes both the RSF header files and the binary files&lt;br /&gt;
that the headers point to. &lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 &amp;gt; spike.rsf datapath=./&lt;br /&gt;
bash&amp;amp;#36; sfget in &amp;lt; spike.rsf&lt;br /&gt;
in=./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
spike.rsf  spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; sfrm -v spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing header spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing data ./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
ls: No match.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sfrotate==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Rotate a portion of one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrotate &amp;lt; in.rsf &amp;gt; out.rsf verb=n memsize=sf_memsize() rot#=(0,0,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rot#=(0,0,...)&#039;&#039;&#039; ||   || 	length of #-th axis that is moved to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt; modifies the input dataset by splitting it into&lt;br /&gt;
parts and putting the parts back in a different order. Here is a quick example.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the first axis by putting the last two columns in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=2 | sfdisfil&lt;br /&gt;
   0:             3            4            0            1            2&lt;br /&gt;
   5:             4            5            1            2            3&lt;br /&gt;
  10:             5            6            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the second axis by putting the last row in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot2=1 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=3 rot2=1 | sfdisfil&lt;br /&gt;
   0:             4            5            6            2            3&lt;br /&gt;
   5:             2            3            4            0            1&lt;br /&gt;
  10:             3            4            5            1            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The transformation is shown schematically in Figure~(fig:rotate).&lt;br /&gt;
[[Image:rotate.png|frame|center|Schematic transformation of data with &amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
&lt;br /&gt;
==sfrtoc==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;See also: sfcmplx&lt;br /&gt;
|}&lt;br /&gt;
The input to &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; can be any &amp;lt;tt&amp;gt;type=float&amp;lt;/tt&amp;gt; dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 n2=20 n3=30 &amp;gt;real.rsf&lt;br /&gt;
bash$ sfin real.rsf&lt;br /&gt;
real.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/real.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output dataset will have &amp;lt;tt&amp;gt;type=complex&amp;lt;/tt&amp;gt;, and its binary will be twice the size of the input:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt;real.rsf sfrtoc &amp;gt;complex.rsf&lt;br /&gt;
bash$ sfin complex.rsf &lt;br /&gt;
complex.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/complex.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 48000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfscale==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Scale data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfscale &amp;lt; in.rsf &amp;gt; out.rsf axis=0 rscale=0. dscale=1.&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;To scale by a constant factor, you can also use sfmath or sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=0&#039;&#039;&#039; ||   || 	Scale by maximum in the dimensions up to this axis.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dscale=1.&#039;&#039;&#039; ||   || 	Scale by this factor (works if rscale=0)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;rscale=0.&#039;&#039;&#039; ||   || 	Scale by this factor.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfscale&amp;lt;/tt&amp;gt; scales the input dataset by a factor. Here&lt;br /&gt;
are some simple examples. First, let us create a test dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil   &lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Scale every data point by 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale dscale=2 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
   5:             4            8           12           16           20&lt;br /&gt;
  10:             6           12           18           24           30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide every trace by its maximum value:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=1 | sfdisfil&lt;br /&gt;
   0:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
   5:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide by the maximum value in the whole 2-D dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=2 | sfdisfil&lt;br /&gt;
   0:       0.06667       0.1333          0.2       0.2667       0.3333&lt;br /&gt;
   5:        0.1333       0.2667          0.4       0.5333       0.6667&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;rscale=&amp;lt;/tt&amp;gt; parameter is synonymous to &amp;lt;tt&amp;gt;dscale=&amp;lt;/tt&amp;gt; except&lt;br /&gt;
when it is equal to zero. With &amp;lt;tt&amp;gt;sfscale dscale=0&amp;lt;/tt&amp;gt;, the dataset gets&lt;br /&gt;
multiplied by zero. If using &amp;lt;tt&amp;gt;rscale=0&amp;lt;/tt&amp;gt;, the other parameters are&lt;br /&gt;
used to define scaling.  Thus, &amp;lt;tt&amp;gt;sfscale rscale=0 axis=1&amp;lt;/tt&amp;gt; is&lt;br /&gt;
equivalent to &amp;lt;tt&amp;gt;sfscale axis=1&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfscale rscale=0&amp;lt;/tt&amp;gt;&lt;br /&gt;
is equivalent to &amp;lt;tt&amp;gt;sfscale dscale=1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfspike==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate simple data: spikes, boxes, planes, constants. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspike &amp;gt; spike.rsf mag= nsp=1 k#=[0,...] l#=[k1,k2,...] p#=[0,...] n#= o#=[0,0,...] d#=[0.004,0.1,0.1,...] label#=[Time,Distance,Distance,...] unit#=[s,km,km,...] title=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Spike positioning is given in samples and starts with 1.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=[0.004,0.1,0.1,...]&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;k#=[0,...]&#039;&#039;&#039; ||   || 	spike starting position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;l#=[k1,k2,...]&#039;&#039;&#039; ||   || 	spike ending position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=[Time,Distance,Distance,...]&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;mag=&#039;&#039;&#039; ||   || 	spike magnitudes  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nsp=1&#039;&#039;&#039; ||   || 	Number of spikes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o#=[0,0,...]&#039;&#039;&#039; ||   || 	origin on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;p#=[0,...]&#039;&#039;&#039; ||   || 	spike inclination (in samples)  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || 	title for plots&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=[s,km,km,...]&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; takes no input and generates an output with&lt;br /&gt;
&amp;quot;spikes&amp;quot;. It is an easy way to create data. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 k2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The spike location is specified by parameters &amp;lt;tt&amp;gt;k1=4&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;k2=1&amp;lt;/tt&amp;gt;. Note that the locations are numbered starting from 1. &lt;br /&gt;
If one of the parameters is omitted or given the value of zero, the &lt;br /&gt;
spike in the corresponding direction becomes a plane:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 | sfdisfil   &lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            1            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If no spike parameters are given, the whole dataset is filled with ones:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create several spikes, use the &amp;lt;tt&amp;gt;nsp=&amp;lt;/tt&amp;gt; parameter and give a comma-separated list of values to &amp;lt;tt&amp;gt;k#=&amp;lt;/tt&amp;gt; arguments:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the number of values in the list is smaller than &amp;lt;tt&amp;gt;nsp&amp;lt;/tt&amp;gt;, the&lt;br /&gt;
last value gets repeated, and the spikes add on top of each other,&lt;br /&gt;
creating larger amplitudes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3 k2=1,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            2            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The magnitude of the spikes can be controlled explicitly with the&lt;br /&gt;
&amp;lt;tt&amp;gt;mag=&amp;lt;/tt&amp;gt; parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 mag=1,4,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            4            0            0&lt;br /&gt;
  10:             0            0            0            2            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can create boxes instead of spikes by using &amp;lt;tt&amp;gt;l#=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 l1=4 k2=2 mag=8 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            8            8            8            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, &amp;lt;tt&amp;gt;k1=2&amp;lt;/tt&amp;gt; specifies the box start, and &amp;lt;tt&amp;gt;l1=4&amp;lt;/tt&amp;gt;&lt;br /&gt;
specifies the box end.&lt;br /&gt;
Finally, multi-dimensional planes can be given an inclination by using &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=1 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; interprets the &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters in stepout from sample to sample, not in terms of axes units (i.e. s/m). &lt;br /&gt;
&lt;br /&gt;
More than one p parameter can be specified. In this case, a (hyper) plane will be created.&lt;br /&gt;
&lt;br /&gt;
When the inclination value is not integer, simple linear interpolation is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=0.7 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0          0.3          0.7            0            0&lt;br /&gt;
  10:             0            0          0.6          0.4            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; supplies default dimensions and labels to all axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the first axis is assumed to be time, with sampling of&lt;br /&gt;
&amp;lt;math&amp;gt;0.004&amp;lt;/math&amp;gt; seconds. All other axes are assumed to be distance, with&lt;br /&gt;
sampling of &amp;lt;math&amp;gt;0.1&amp;lt;/math&amp;gt; kilometers. All these parameters can be changed on&lt;br /&gt;
the command line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 label3=Offset unit3=ft d3=20 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=20          o3=0          label3=&amp;quot;Offset&amp;quot; unit3=&amp;quot;ft&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfspray==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extend a dataset by duplicating in the specified axis dimension.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspray &amp;lt; in.rsf &amp;gt; out.rsf axis=2 n= d= o= label= unit=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    This operation is adjoint to sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to spray&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d=&#039;&#039;&#039; ||   || 	Sampling of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	Label of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n=&#039;&#039;&#039; ||   || 	Size of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o=&#039;&#039;&#039; ||   || 	Origin of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	Units of the newly created dimension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; extends the input hypercube by replicating the data&lt;br /&gt;
in one of the dimensions. The output dataset acquires one additional&lt;br /&gt;
dimension. Here is an example:&lt;br /&gt;
Start with a 2-D dataset&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=2 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extend the data in the second dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=2 n=3 &amp;gt; test2.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=3           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=1           o3=0          &lt;br /&gt;
        30 elements 120 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test2.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
  20:             1            2            3            4            5&lt;br /&gt;
  25:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is three-dimensional, with traces from the original&lt;br /&gt;
data duplicated along the second axis.&lt;br /&gt;
Extend the data in the third dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=3 n=2 &amp;gt; test3.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test3.rsf&lt;br /&gt;
test3.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test3.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=?           o3=?          &lt;br /&gt;
        20 elements 80 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test3.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is also three-dimensional, with the original data replicated&lt;br /&gt;
along the third axis.&lt;br /&gt;
&lt;br /&gt;
==sfstack==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stack a dataset over one of the dimensions.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstack &amp;lt; in.rsf &amp;gt; out.rsf axis=2 rms=n norm=y min=n max=n&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;This operation is adjoint to sfspray.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to stack&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;max=n&#039;&#039;&#039; ||  [y/n] || 	If y, find maximum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;min=n&#039;&#039;&#039; ||  [y/n] || 	If y, find minimum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	If y, normalize by fold.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rms=n&#039;&#039;&#039; ||  [y/n] || 	If y, compute the root-mean-square instead of stack.&lt;br /&gt;
|}&lt;br /&gt;
While &amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; adds a dimension to a hypercube,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; effectively removes one of the dimensions by stacking&lt;br /&gt;
over it. Here are some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=2 | sfdisfil&lt;br /&gt;
   0:           1.5            2            3            4            5&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 | sfdisfil&lt;br /&gt;
   0:           2.5            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Why is the first value not 1 (in the first case) or 2 (in the second&lt;br /&gt;
case)? By default, &amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; normalizes the stack by the fold&lt;br /&gt;
(the number of non-zero entries). To avoid normalization, use&lt;br /&gt;
&amp;lt;tt&amp;gt;norm=n&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack norm=n | sfdisfil &lt;br /&gt;
   0:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; can also compute root-mean-square values as &lt;br /&gt;
well as minimum and maximum values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack rms=y | sfdisfil&lt;br /&gt;
   0:         1.581         2.16        3.109        4.082        5.066&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack min=y | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 max=y | sfdisfil &lt;br /&gt;
   0:             4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sftransp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Transpose two axes in a dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sftransp &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() plane=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;If you get a &amp;quot;Cannot allocate memory&amp;quot; error, give the program a&amp;lt;br&amp;gt;memsize=1 command-line parameter to force out-of-core operation.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plane=&#039;&#039;&#039; ||   || 	Two-digit number with axes to transpose. The default is 12&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; program transposes the input hypercube&lt;br /&gt;
exchanging the two axes specified by the &amp;lt;b&amp;gt;plane=&amp;lt;/b&amp;gt; parameter. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 n2=20 n3=30 &amp;gt; orig123.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin orig123.rsf &lt;br /&gt;
orig123.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/orig123.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=23 &amp;gt;out132.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out132.rsf &lt;br /&gt;
out132.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=30          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=20          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=13 &amp;gt;out321.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out321.rsf &lt;br /&gt;
out321.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=30          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=10          d3=0.004       o3=0          label3=&amp;quot;Time&amp;quot; unit3=&amp;quot;s&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; tries to fit the dataset in memory to transpose it&lt;br /&gt;
there but, if not enough memory is available, it performs a slower&lt;br /&gt;
transpose out of core using disk operations. You can control the&lt;br /&gt;
amount of available memory using the &amp;lt;b&amp;gt;memsize=&amp;lt;/b&amp;gt; parameter or&lt;br /&gt;
the &amp;lt;b&amp;gt;RSFMEMSIZE&amp;lt;/b&amp;gt; environmental variable.&lt;br /&gt;
&lt;br /&gt;
==sfwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwindow &amp;lt; in.rsf &amp;gt; out.rsf verb=n squeeze=y j#=(1,...) d#=(d1,d2,...) f#=(0,...) min#=(o1,o2,,...) n#=(0,...) max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(d1,d2,...)&#039;&#039;&#039; ||   || 	sampling in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;f#=(0,...)&#039;&#039;&#039; ||   || 	window start in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;j#=(1,...)&#039;&#039;&#039; ||   || 	jump in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&#039;&#039;&#039; ||   || 	maximum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min#=(o1,o2,,...)&#039;&#039;&#039; ||   || 	minimum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=(0,...)&#039;&#039;&#039; ||   || 	window size in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;squeeze=y&#039;&#039;&#039; ||  [y/n] || 	if y, squeeze dimensions equal to 1 to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; is used to window a portion of the dataset. Here is&lt;br /&gt;
a quick example: Start by creating some data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now window the first two rows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n2=2 | sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the first three columns:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n1=3 | sfdisfil&lt;br /&gt;
   0:             1            2            3            2            4&lt;br /&gt;
   5:             6            3            6            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the middle row:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can interpret the &amp;lt;b&amp;gt;f#&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;n#&amp;lt;/b&amp;gt; parameters as&lt;br /&gt;
meaning &amp;quot;skip that many rows/columns&amp;quot; and &amp;quot;select that many&lt;br /&gt;
rows/columns&amp;quot; correspondingly. Window the middle point in the dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f1=2 n1=1 f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every other column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=2 | sfdisfil&lt;br /&gt;
   0:             1            3            5            2            6&lt;br /&gt;
   5:            10            3            9           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every third column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=3 | sfdisfil&lt;br /&gt;
   0:             1            4            2            8            3&lt;br /&gt;
   5:            12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; can use the minimum and maximum&lt;br /&gt;
parameters to select a window. In the following example, we are&lt;br /&gt;
creating a dataset with &amp;lt;b&amp;gt;sfspike&amp;lt;/b&amp;gt; and then windowing a portion of it&lt;br /&gt;
between 1 and 2 seconds in time and sampled at 8 miliseconds.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=1000 n2=10 &amp;gt; spike.rsf         &lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1000        d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10000 elements 40000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow min1=1 max1=2 d1=0.008 &amp;gt; window.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin window.rsf&lt;br /&gt;
window.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/window.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=126         d1=0.008       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        1260 elements 5040 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
By default, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; &amp;quot;squeezes&amp;quot; the hypercube dimensions&lt;br /&gt;
that are equal to one toward the end of the dataset. Here is an&lt;br /&gt;
example of taking a time slice:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=1           d2=0.004       o2=1          label2=&amp;quot;Time&amp;quot; unit2=&amp;quot;s&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can change this behavior by specifying &amp;lt;b&amp;gt;squeeze=n&amp;lt;/b&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 squeeze=n &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1           d1=0.004       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Seismic programs=&lt;br /&gt;
Programs in this category are specific for operations on seismic data. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/seismic/ system/seismic] in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sffkamo==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Computes Azimuth Move-Out (AMO) operator in the f-k log-stretch domain &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffkamo &amp;lt; in.rsf &amp;gt; out.rsf h1= h2= f1= f2= maxe=10.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f1=&#039;&#039;&#039; ||   || 	input azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f2=&#039;&#039;&#039; ||   || 	output azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h1=&#039;&#039;&#039; ||   || 	input offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h2=&#039;&#039;&#039; ||   || 	output offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxe=10.&#039;&#039;&#039; ||   || 	stability constraint&lt;br /&gt;
|}&lt;br /&gt;
Sample workflow from [http://m8r.info/RSF/book/sep/fkamo/paper_html/ SEP-110, 63-70 (2001)], with the addition of a bandpass for the input:&lt;br /&gt;
&lt;br /&gt;
Create input -- a (t,x,y) common-offset cube:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike \&lt;br /&gt;
n1=128 o1=0.4 d1=0.0032 k1=65 label1=t \&lt;br /&gt;
n2=256 o2=-1.536 d2=0.012 k2=129 label2=x \&lt;br /&gt;
n3=128 o3=-1.024 d3=0.016 k3=65 label3=y | \&lt;br /&gt;
sfbandpass flo=5 fhi=60 &amp;gt; spikebps.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply log-stretch FFT:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebps.rsf sfstretch rule=L dens=4 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 &amp;gt; spikefft3.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compute AMO operator for a file of the dimensions of &amp;lt;tt&amp;gt;spikefft3.rsf&amp;lt;/tt&amp;gt;. The only information taken from stdin are the n, o, d parameters:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikefft3.rsf sffkamo h2=2 f2=10 h1=1.8 f1=30 &amp;gt;oper.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the operator by multiplication and fft back to (t, mx, my):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikefft3.rsf sfadd mode=prod oper.rsf |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfstretch rule=L dens=4 inv=y &amp;gt; spikeamo.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prepare for 8-bit greyscale visualization:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sfbyte pclip=100 gainpanel=a &amp;gt; spikebyte.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture from the middle of the impulse response:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebyte.rsf sfgrey3 frame1=65 frame2=129 frame3=65 \&lt;br /&gt;
point1=0.333 title=&#039;AMO saddle, no f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture illustrating the artifacts (i.e. need for f-k filter):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikebyte.rsf sfgrey3 frame1=65 frame2=97 frame3=97 \&lt;br /&gt;
point1=0.333 title=&#039;No f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the f-k filter and (in this case) visualize:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 |\&lt;br /&gt;
sfdipfilter v1=-2.5 v2=-1.5 v3=1.5 v4=2.5 taper=2 pass=0 dim=3 |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfbyte pclip=100 gainpanel=a |\&lt;br /&gt;
sfgrey3 frame1=65 frame2=97 frame3=97 point1=0.333 title=&#039;With f-k filter&#039; |\&lt;br /&gt;
sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheaderattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Integer header attributes. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderattr &amp;lt; head.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Only nonzero values are reported.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; examines the contents of a trace header file,&lt;br /&gt;
typically generated by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;. In the example below, we examine&lt;br /&gt;
trace headers in the output of &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt;, a program from Seismic Unix.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
bash$ sfheaderattr &amp;lt; tfile.rsf&lt;br /&gt;
*******************************************&lt;br /&gt;
71 headers, 32 traces&lt;br /&gt;
key[0]=&amp;quot;tracl&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[1]=&amp;quot;tracr&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[11]=&amp;quot;offset&amp;quot;    min[0]=400          max[31]=400         mean=400&lt;br /&gt;
key[38]=&amp;quot;ns&amp;quot;        min[0]=64           max[31]=64          mean=64&lt;br /&gt;
key[39]=&amp;quot;dt&amp;quot;        min[0]=4000         max[31]=4000        mean=4000&lt;br /&gt;
*******************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For different standard keywords, a minimum, maximum, and mean values&lt;br /&gt;
are reported unless they are identically zero.  This quick inspection&lt;br /&gt;
can help in identifying meaningful keywords set in the data. The input&lt;br /&gt;
data type must be &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfheadermath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations, possibly on header keys. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadermath &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also sfmath. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An addition operation can be performed by sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Describes the output in a mathematical notation.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; is a versatile program for mathematical&lt;br /&gt;
operations on rows of the input file. If the input file is an&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; by &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix, the output will be a &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; by&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix that contains one row made out of mathematical&lt;br /&gt;
operations on the other rows. &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; can identify a row&lt;br /&gt;
by number or by a standard SEGY keyword. The latter is useful for&lt;br /&gt;
processing headers extracted from SEGY or SU files.&lt;br /&gt;
Here is an example. First, we create an SU file with &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt; and convert it to RSF using &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The trace header information is saved in &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt;. It&lt;br /&gt;
contains 71 headers for 32 traces in integer format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin tfile.rsf&lt;br /&gt;
tfile.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/tfile.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=int form=native&lt;br /&gt;
    n1=71          d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        2272 elements 9088 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we will convert &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt; to a floating-point format&lt;br /&gt;
and run &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; to create a new header.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; tfile.rsf sfdd type=float | \&lt;br /&gt;
sfheadermath myheader=1 output=&amp;quot;sqrt(myheader+(2+10*offset^2))&amp;quot; &amp;gt; new.rsf&lt;br /&gt;
bash$ sfin new.rsf&lt;br /&gt;
new.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/new.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1           d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        32 elements 128 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We defined &amp;quot;myheader&amp;quot; as being the row number 1 in the input (note&lt;br /&gt;
that numbering starts with 0) and combined it with &amp;quot;offset&amp;quot;, which&lt;br /&gt;
is a standard SEGY keyword that denotes row number 11 (see the output&lt;br /&gt;
of &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; above.) A variety of mathematical expressions&lt;br /&gt;
can be defined in the &amp;lt;tt&amp;gt;output=&amp;lt;/tt&amp;gt; string. The expression&lt;br /&gt;
processing engine is shared with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfsegyheader==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Make a trace header file for segywrite.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyheader &amp;lt; in.rsf &amp;gt; out.rsf n1= d1=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;   Use the output for tfile= argument in segywrite.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=&#039;&#039;&#039; ||   ||      trace sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=&#039;&#039;&#039; ||   ||      number of samples in a trace&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==sfsegyread==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a SEG-Y or SU dataset to RSF.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyread mask=msk.rsf &amp;gt; out.rsf tfile=hdr.rsf verb=n su= suxdr=n endian=y format=segyformat (bhead) ns=segyns (bhead) tape= read= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Data headers and trace headers are separated from the data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;suread&amp;quot; is equivalent to &amp;quot;segyread su=y&amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;SEGY key names:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracl: trace sequence number within line 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracr: trace sequence number within reel 4&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;fldr:     field record number 8 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracf:    trace number within field record 12 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ep:       energy source point number 16 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdp:      CDP ensemble number 20 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpt:     trace number within CDP ensemble 24 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trid:     trace identification code:&amp;lt;br&amp;gt;1 = seismic data&amp;lt;br&amp;gt;2 = dead&amp;lt;br&amp;gt;3 = dummy&amp;lt;br&amp;gt;4 = time break&amp;lt;br&amp;gt;5 = uphole&amp;lt;br&amp;gt;6 = sweep&amp;lt;br&amp;gt;7 = timing&amp;lt;br&amp;gt;8 = water break&amp;lt;br&amp;gt;9---, N = optional use (N = 32,767) 28 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nvs:      number of vertically summed traces 30 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nhs:      number of horizontally summed traces 32 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;duse:     data use:&amp;lt;br&amp;gt;1 = production&amp;lt;br&amp;gt;2 = test 34&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;offset:   distance from source point to receiver&amp;lt;br&amp;gt;group (negative if opposite to direction&amp;lt;br&amp;gt;in which the line was shot) 36 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gelev:    receiver group elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 40 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;selev:    source elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 44 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdepth:   source depth (positive) 48 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gdel:     datum elevation at receiver group 52 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdel:     datum elevation at source 56 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swdep:    water depth at source 60 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gwdep:    water depth at receiver group 64 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalel:   scale factor for previous 7 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 68 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalco:   scale factor for next 4 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 70 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sx:       X source coordinate 72 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sy:       Y source coordinate 76 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gx:       X group coordinate 80 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gy:       Y group coordinate 84 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;counit:   coordinate units code:&amp;lt;br&amp;gt;for previous four entries&amp;lt;br&amp;gt;1 = length (meters or feet)&amp;lt;br&amp;gt;2 = seconds of arc (in this case, the&amp;lt;br&amp;gt;X values are unsigned longitude and the Y values&amp;lt;br&amp;gt;are latitude, a positive value designates&amp;lt;br&amp;gt;the number of seconds east of Greenwich&amp;lt;br&amp;gt;or north of the equator 88 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;wevel:     weathering velocity 90 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swevel:    subweathering velocity 92 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sut:       uphole time at source 94 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gut:       uphole time at receiver group 96 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sstat:     source static correction 98 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gstat:     group static correction 100 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tstat:     total static applied 102 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;laga:      lag time A, time in ms between end of 240-&amp;lt;br&amp;gt;byte trace identification header and time&amp;lt;br&amp;gt;break, positive if time break occurs after&amp;lt;br&amp;gt;end of header, time break is defined as&amp;lt;br&amp;gt;the initiation pulse which maybe recorded&amp;lt;br&amp;gt;on an auxiliary trace or as otherwise&amp;lt;br&amp;gt;specified by the recording system 104 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lagb:      lag time B, time in ms between the time&amp;lt;br&amp;gt;break and the initiation time of the energy source,&amp;lt;br&amp;gt;may be positive or negative 106 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;delrt:     delay recording time, time in ms between&amp;lt;br&amp;gt;initiation time of energy source and time&amp;lt;br&amp;gt;when recording of data samples begins&amp;lt;br&amp;gt;(for deep water work if recording does not&amp;lt;br&amp;gt;start at zero time) 108 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;muts:      mute time--start 110 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;mute:      mute time--end 112 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ns:        number of samples in this trace 114 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;dt:        sample interval, in micro-seconds 116 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gain:      gain type of field instruments code:&amp;lt;br&amp;gt;1 = fixed&amp;lt;br&amp;gt;2 = binary&amp;lt;br&amp;gt;3 = floating point&amp;lt;br&amp;gt;4 ---- N = optional use 118 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igc:       instrument gain constant 120 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igi:       instrument early or initial gain 122 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;corr:      correlated:&amp;lt;br&amp;gt;1 = no&amp;lt;br&amp;gt;2 = yes 124&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfs:       sweep frequency at start 126 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfe:       sweep frequency at end 128 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;slen:      sweep length in ms 130 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;styp:      sweep type code:&amp;lt;br&amp;gt;1 = linear&amp;lt;br&amp;gt;2 = cos-squared&amp;lt;br&amp;gt;3 = other 132&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stas:      sweep trace length at start in ms 134 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stae:      sweep trace length at end in ms 136 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tatyp:     taper type: 1=linear, 2=cos^2, 3=other 138 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afilf:     alias filter frequency if used 140 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afils:     alias filter slope 142 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofilf:    notch filter frequency if used 144 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofils:    notch filter slope 146 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcf:       low cut frequency if used 148 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcf:       high cut frequncy if used 150 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcs:       low cut slope 152 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcs:       high cut slope 154 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;year:      year data recorded 156 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;day:       day of year 158 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hour:      hour of day (24 hour clock) 160 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;minute:    minute of hour 162 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sec:       second of minute 164 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;timbas:    time basis code:&amp;lt;br&amp;gt;1 = local&amp;lt;br&amp;gt;2 = GMT&amp;lt;br&amp;gt;3 = other 166&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trwf:      trace weighting factor, defined as 1/2^N&amp;lt;br&amp;gt;volts for the least sigificant bit 168 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnors:    geophone group number of roll switch&amp;lt;br&amp;gt;position one 170&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnofr:    geophone group number of trace one within&amp;lt;br&amp;gt;original field record 172&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnlof:    geophone group number of last trace within&amp;lt;br&amp;gt;original field record 174&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gaps:      gap size (total number of groups dropped) 176 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;otrav:     overtravel taper code: &amp;lt;br&amp;gt;1 = down (or behind)&amp;lt;br&amp;gt;2 = up (or ahead) 178&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpx:   X coordinate of CDP 180&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpy:   Y coordinate of CDP 184&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;iline:  in-line number 188 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;xline:  cross-line number 192&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shnum:  shotpoint number 196&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shsca:  shotpoint scalar 200&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tval:   trace value meas. 202&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst4: transduction const 204&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst2: transduction const 208&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tunits:  transduction units 210&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;device:  device identifier 212&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tscalar: time scalar 214&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stype:   source type 216&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sendir:  source energy dir. 218&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;unknown: unknown 222&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas4:  source measurement 224&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas2:  source measurement 228&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeasu:  source measurement unit 230 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass1:  unassigned 232&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass2:  unassigned 236&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   || 	output binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=y&#039;&#039;&#039; ||  [y/n] || 	Whether to automatically estimate endianness or not&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;format=segyformat (bhead)&#039;&#039;&#039; ||  [1,2,3,5] || 	Data format. The default is taken from binary header.&lt;br /&gt;
:1 is IBM floating point&lt;br /&gt;
:2 is 4-byte integer&lt;br /&gt;
:3 is 2-byte integer&lt;br /&gt;
:5 is IEEE floating point&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   || 	output text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	optional header mask for reading only selected traces (auxiliary input file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ns=segyns (bhead)&#039;&#039;&#039; ||   || 	Number of samples. The default is taken from binary header&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;read=&#039;&#039;&#039; ||   || 	what to read: h - header, d - data, b - both (default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=&#039;&#039;&#039; ||  [y/n] || 	y if input is SU, n if input is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;suxdr=n&#039;&#039;&#039; ||  [y/n] || 	y, SU has XDR support&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   || 	input data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tfile=&#039;&#039;&#039; ||   || 	output trace header file (auxiliary output file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The SEG Y format is an [http://en.wikipedia.org/wiki/Open_standard open standard] for the exchange of geophysical data. It is controlled by the non-profit [http://www.seg.org/SEGportalWEBproject/portals/SEG_Online.portal?_nfpb=true&amp;amp;_pageLabel=pg_gen_content&amp;amp;Doc_Url=prod/SEG-Publications/Pub-Yearbook/committees.htm SEG Technical Standards Committee]. There are two versions of this standard: [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev0.pdf rev0] (1975)&amp;lt;ref&amp;gt;Barry, K.M., Cavers, D.A., and Kneale, C.W. 1975. Recommended standards for digital tape formats. &#039;&#039;Geophysics&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, no. 02, 344–352.&amp;lt;/ref&amp;gt; and [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf rev1] (2002)&amp;lt;ref&amp;gt;Norris, M.W., Faichney, A.K., &#039;&#039;Eds&#039;&#039;. 2001. SEG Y rev1 Data Exchange format. Society of Exploration Geophysicists, Tulsa, OK, 45 pp.&amp;lt;/ref&amp;gt;. The implementation in &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; is a mixture of rev0 (i.e. no checks for Extended Textual Headers) and rev1 ([http://en.wikipedia.org/wiki/IEEE_floating-point_standard IEEE floating point format] allowed for trace data samples).&lt;br /&gt;
&lt;br /&gt;
A SEG-Y file as understood by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; contains a &amp;quot;Reel Identification Header&amp;quot; (3200 bytes in EBCDIC followed by 400 bytes in a binary encoding), followed by a number of &amp;quot;Trace Blocks&amp;quot;. Each &amp;quot;Trace Block&amp;quot; contains a 240-byte &amp;quot;Trace Header&amp;quot; (binary) followed by &amp;quot;Trace Data&amp;quot; -- a sequence of &amp;lt;tt&amp;gt;ns&amp;lt;/tt&amp;gt; samples. Binary values in both reel headers and trace headers are two&#039;s complement integers, either two bytes or four bytes long. There are no floating-point values defined in the headers. Trace Data samples can have various encodings, either floating point or integer, described further down, but they are all big-endian. To convert from SEG-Y to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will strip the tape reel EBCDIC header and convert it to ASCII, will extract the reel binary header without changing it, and will put the trace headers into one RSF file, and the traces themselves on another.&lt;br /&gt;
&lt;br /&gt;
===SEG-Y Trace Headers===&lt;br /&gt;
In the SEG-Y standard, only the first 180 bytes of the 240-byte trace header are defined; bytes 181-240 are reserved for non-standard header information, and these locations are increasingly used in modern SEG-Y files and its variants. The standard provides for a total of 71 4-byte and 2-byte predefined header words. These 71 standard words have defined lengths and byte offsets, and only these words and byte locations are read using &amp;lt;tt&amp;gt;segyread&amp;lt;/tt&amp;gt; and output to the RSF header file with the &amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; option. The user may remap these predefined keywords to a different byte offsets.&lt;br /&gt;
&lt;br /&gt;
===SU File Format===&lt;br /&gt;
An [http://www.cwp.mines.edu/sututor/node22.html SU file] is nothing more than a SEG-Y file without the reel headers, and with the Trace Data samples in the native encoding of the CPU the file was created on (Attention -- limited portability!). So, to convert from SU to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will just separate headers and traces into two RSF files. &lt;br /&gt;
&lt;br /&gt;
===SEG-Y specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; specifies the name of the file in which the EBCDIC reel header will be put after conversion to ASCII. If you are certain there is no useful information in it, &amp;lt;tt&amp;gt;hfile=/dev/null&amp;lt;/tt&amp;gt; works just fine. If you do not specify anything for this parameter you will get an ASCII file named &amp;lt;tt&amp;gt;header&amp;lt;/tt&amp;gt; in the current directory. If you want to quickly preview this header before running &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;, use&amp;lt;pre&amp;gt;dd if=input.segy count=40 bs=80 cbs=80 conv=unblock,ascii&amp;lt;/pre&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;bfile=&amp;lt;/tt&amp;gt; specifies name of the file in which the binary reel header (the 400-bytes thing following the 3600-bytes EBCDIC) will be put without any conversion. The default name is &amp;quot;binary&amp;quot;. Unless you have software that knows how to read exactly this special type of file, it will be completely useless, so do &amp;lt;tt&amp;gt;bfile=/dev/null&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;format=&amp;lt;/tt&amp;gt; specifies the format in which the trace data samples are in the SEG-Y input file. This is read from the binary reel header of the SEG-Y file. Valid values are 1(IBM floating point), 2 (4-byte integer), 3 (2-byte integer) and 5 (IEEE floating point). If the input file is SU, the format will be assumed to be the native &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;tt&amp;gt;keyname=&amp;lt;/tt&amp;gt; specifies the byte offset to remap a header using the trace header key names shown above. For example, if the CDP locations have been placed in bytes 181-184 instead of the standard 21-24, &amp;lt;tt&amp;gt;cdp=180&amp;lt;/tt&amp;gt; will remap the trace header to that location. &lt;br /&gt;
&lt;br /&gt;
===SU-specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;suxdr=&amp;lt;/tt&amp;gt; specifies whether the input file was created with a SU package with XDR support enabled. If you have access to the source code of your SU install (try &amp;lt;tt&amp;gt;$CWPROOT/src&amp;lt;/tt&amp;gt;), type: &amp;lt;tt&amp;gt;grep &#039;XDRFLAG =&#039; $CWPROOT/src/Makefile.config&amp;lt;/tt&amp;gt; and look at the last uncommented entry. If no value is given for &amp;lt;tt&amp;gt;XDRFLAG&amp;lt;/tt&amp;gt;, the package was not compiled with XDR support.&lt;br /&gt;
===Common parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;su=&amp;lt;/tt&amp;gt; specifies if the input file is SU or SEG-Y. Default is &amp;lt;tt&amp;gt;su=n&amp;lt;/tt&amp;gt; (SEG-Y file).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; specifies the input data. Stdin could not be used because &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; has to work with tapes, and needs to fseek back and forth through the input file. Thankfully, output is on stdout.&lt;br /&gt;
*&amp;lt;tt&amp;gt;read=&amp;lt;/tt&amp;gt; specifies what parts of the &amp;quot;Trace Blocks&amp;quot; will be read. It can be &amp;lt;tt&amp;gt;read=t&amp;lt;/tt&amp;gt; (only trace data is read), &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; (only trace headers are read) or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt; (both are read).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tfile=&amp;lt;/tt&amp;gt; gives the name of the RSF file to which trace headers are written. Obviously, it should be only specified with &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;mask=&amp;lt;/tt&amp;gt; is an optional parameter specifying the name of a mask that says which traces will be read. The mask is a 1-D RSF file with integers. The number of samples in the mask is the same as the number of traces in the unmasked SEG-Y. In places corresponding to unwanted traces there should be zeros in the mask.&lt;br /&gt;
*&amp;lt;tt&amp;gt;ns=&amp;lt;/tt&amp;gt; specifies the number of samples in a trace. For SEG-Y files, the default is taken from the binary reel header, and for SU files, from the header of the first trace. This parameter is however critical enough that a command line override was given for it.&lt;br /&gt;
*&amp;lt;tt&amp;gt;verbose=&amp;lt;/tt&amp;gt; is the verbosity flag. Can be &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;endian=&amp;lt;/tt&amp;gt; is a y/n flag (default y), specifying whether to automatically estimate or not if samples in the Trace Data blocks are big-endian or little-endian. Try it if you are in trouble and do not know what else to do, otherwise let the automatic estimation do its job.&lt;br /&gt;
&lt;br /&gt;
==sfsegywrite==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert an RSF dataset to SEGY or SU.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegywrite &amp;lt; in.rsf tfile=hdr.rsf verb=false su=false endian=sf_endian() tape= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Merges trace headers with data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   ||   input binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=sf_endian()&#039;&#039;&#039; ||  [y/n] ||  big/little endian flag. The default is estimated automatically&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   ||   input text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=n&#039;&#039;&#039; ||  [y/n] ||        y if output is SU, n if output is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] ||   Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
Please see &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; for a complete description of parameter meanings and background issues. Parameters &amp;lt;tt&amp;gt;bfile&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;hfile&amp;lt;/tt&amp;gt; should only be given values when the desired file is SEG-Y (default). The output file is specified by the &amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; tag.&lt;br /&gt;
=Generic programs=&lt;br /&gt;
Programs in this category are general signal and image processing programs. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/generic/ system/generic] in the Madagascar distribution.&lt;br /&gt;
==sfnoise==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add random noise to the data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfnoise &amp;lt; in.rsf &amp;gt; out.rsf seed=time(NULL) type=y var= range= mean=0 rep=n&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;mean=0&#039;&#039;&#039; ||   || 	noise mean&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;range=&#039;&#039;&#039; ||   || 	noise range (default=1)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rep=n&#039;&#039;&#039; ||  [y/n] || 	if y, replace data with noise&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;seed=time(NULL)&#039;&#039;&#039; ||   || 	random seed&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;type=y&#039;&#039;&#039; ||  [y/n] || 	noise distribution, y: normal, n: uniform&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;var=&#039;&#039;&#039; ||   || 	noise variance&lt;br /&gt;
|}&lt;br /&gt;
See the [http://www.ahay.org/rsflog/index.php?/archives/262-Program-of-the-month-sfnoise.html Program of the Month] blog entry.&lt;br /&gt;
&lt;br /&gt;
=Plotting programs (stable)=&lt;br /&gt;
The source files for these programs can be found under&lt;br /&gt;
[http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/plot/main/ plot/main]&lt;br /&gt;
in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sfbox==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Draw a balloon-style label.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfbox lab_color=VP_WHITE lab_fat=0 pscale=1. pointer=y reverse=n lat=0. long=90. angle=0. x0=0. y0=0. scale0=1. xt=2. yt=0. x_oval=0. y_oval=0. boxit=y length= scalet= size=.25 label= &amp;gt; out.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;angle=0.&#039;&#039;&#039; ||   || 	longitude of floating label in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;boxit=y&#039;&#039;&#039; ||  [y/n] || 	if y, create a box around text&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_color=VP_WHITE&#039;&#039;&#039; ||   || 	label color&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_fat=0&#039;&#039;&#039; ||   || 	label fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	text for label&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;lat=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;length=&#039;&#039;&#039; ||   || 	normalization for xt and yt&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;long=90.&#039;&#039;&#039; ||   || 	latitude and longitude of viewpoint in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;pointer=y&#039;&#039;&#039; ||  [y/n] || 	if y, create arrow pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pscale=1.&#039;&#039;&#039; ||   || 	scale factor for width of pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;reverse=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scale0=1.&#039;&#039;&#039; ||   || 	scale factor for x0 and y0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scalet=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;size=.25&#039;&#039;&#039; ||   || 	text height in inches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x0=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x_oval=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xt=2.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y0=0.&#039;&#039;&#039; ||   || 	position of the pointer tip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y_oval=0.&#039;&#039;&#039; ||   || 	size of the oval around pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yt=0.&#039;&#039;&#039; ||   || 	relative position of text&lt;br /&gt;
|}&lt;br /&gt;
==sfcontour==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Contour plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcontour &amp;lt; in.rsf c= min1=o1 min2=o2 max1=o1+(n1-1)*d1 max2=o2+(n2-1)*d2 nc=50 dc= c0= transp=y minval= maxval= allpos=y barlabel= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=y&#039;&#039;&#039; ||  [y/n] || 	contour positive values only&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;barlabel=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;c=&#039;&#039;&#039; ||   || 	 [nc]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;c0=&#039;&#039;&#039; ||   || 	first contour&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dc=&#039;&#039;&#039; ||   || 	contour increment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max1=o1+(n1-1)*d1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max2=o2+(n2-1)*d2&#039;&#039;&#039; ||   || 	data window to plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min1=o1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min2=o2&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nc=50&#039;&#039;&#039; ||   || 	number of contours&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfdots==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot signal with lollipops.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdots &amp;lt; in.rsf labels= dots=(n1 &amp;lt;= 130)? 1: 0 seemean=(bool) (n2 &amp;lt;= 30) strings=(bool) (n1 &amp;lt;= 400) connect=1 corners= silk=n gaineach=y labelsz=8 yreverse=n constsep=n seedead=n transp=n xxscale=1. yyscale=1. clip=-1. overlap=0.9 screenratio=VP_SCREEN_RATIO screenht=VP_STANDARD_HEIGHT screenwd=screenhigh / screenratio radius=dd1/3 label1= unit1= title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=-1.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;connect=1&#039;&#039;&#039; ||   || 	connection type: 1 - diagonal, 2 - bar, 4 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;constsep=n&#039;&#039;&#039; ||  [y/n] || 	if y, use constant trace separation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;corners=&#039;&#039;&#039; ||   || 	number of polygon corners (default is 6)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dots=(n1 &amp;lt;= 130)? 1: 0&#039;&#039;&#039; ||   || 	type of dots: 1 - baloon, 0 - no dots, 2 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;gaineach=y&#039;&#039;&#039; ||  [y/n] || 	if y, gain each trace independently&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;strings&#039;&#039; || &#039;&#039;&#039;labels=&#039;&#039;&#039; ||   || 	trace labels  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;labelsz=8&#039;&#039;&#039; ||   || 	label size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;overlap=0.9&#039;&#039;&#039; ||   || 	trace overlap&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;radius=dd1/3&#039;&#039;&#039; ||   || 	dot radius&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenht=VP_STANDARD_HEIGHT&#039;&#039;&#039; ||   || 	screen height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenratio=VP_SCREEN_RATIO&#039;&#039;&#039; ||   || 	screen aspect ratio&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenwd=screenhigh / screenratio&#039;&#039;&#039; ||   || 	screen width&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seedead=n&#039;&#039;&#039; ||  [y/n] || 	if y, show zero traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=(bool) (n2 &amp;lt;= 30)&#039;&#039;&#039; ||  [y/n] || 	if y, draw axis lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;silk=n&#039;&#039;&#039; ||  [y/n] || 	if y, silky plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;strings=(bool) (n1 &amp;lt;= 400)&#039;&#039;&#039; ||  [y/n] || 	if y, draw strings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xxscale=1.&#039;&#039;&#039; ||   || 	x scaling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse y axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yyscale=1.&#039;&#039;&#039; ||   || 	y scaling&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot for surfaces.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph3 &amp;lt; in.rsf orient=1 min= max= point1=0.5 point2=0.5 frame1=0.5*(min+max) frame2=n1-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;frame1=0.5*(min+max)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n1-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=&#039;&#039;&#039; ||   || 	maximum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=&#039;&#039;&#039; ||   || 	minimum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;orient=1&#039;&#039;&#039; ||   || 	function orientation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Graph plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph &amp;lt; in.rsf symbolsz= pclip=100. transp=n symbol= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;symbol=&#039;&#039;&#039; ||   || 	if set, plot with symbols instead of lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;symbolsz=&#039;&#039;&#039; ||   || 	symbol size (default is 2)  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfgrey3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey3 &amp;lt; in.rsf point1=0.5 point2=0.5 frame1=0 frame2=n2-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y scalebar=n minval= maxval= barreverse=n nreserve=8 bar= color= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Requires an &amp;quot;unsigned char&amp;quot; input (the output of sfbyte).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame1=0&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n2-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || 	if y, draw scalebar&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
for sfgrey and sfgrey3. Examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfgrey==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate raster plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey &amp;lt; in.rsf &amp;gt; out.rsf bar=bar.rsf transp=y yreverse=y xreverse=n gpow= phalf= clip= pclip= gainstep=0.5+n1/256. allpos=n bias=0. polarity=n verb=n scalebar=n minval= maxval= barreverse=n wantframenum=(bool) (n3 &amp;gt; 1) nreserve=8 gainpanel= bar= color= &amp;gt; (plot.vpl | char.rsf)&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Can input char values.&amp;lt;br&amp;gt;If called &amp;quot;byte&amp;quot;, outputs char values.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=n&#039;&#039;&#039; ||  [y/n] || 	if y, assume positive data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;gainpanel=&#039;&#039;&#039; ||   || 	gain reference: &#039;a&#039; for all, &#039;e&#039; for each, or number&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+n1/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=&#039;&#039;&#039; ||   || 	data clip percentile (default is 99)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;phalf=&#039;&#039;&#039; ||   || 	percentage for estimating gpow&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;polarity=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse polarity (white is high by default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the display axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;wantframenum=(bool) (n3 &amp;gt; 1)&#039;&#039;&#039; ||  [y/n] || 	if y, display third axis position in the corner&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=y&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
and examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfplas==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Assembler - convert ascii to vplot. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplas&lt;br /&gt;
|}&lt;br /&gt;
==sfpldb==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Debugger - convert vplot to ascii. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpldb&lt;br /&gt;
|}&lt;br /&gt;
==sfplotrays==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot rays.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplotrays frame=frame.rsf nt=n1*n2 jr=1 frame= &amp;lt; rays.rsf &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;frame=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jr=1&#039;&#039;&#039; ||   || 	skip rays&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nt=n1*n2&#039;&#039;&#039; ||   || 	maximum ray length&lt;br /&gt;
|}&lt;br /&gt;
==sfthplot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Hidden-line surface plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfthplot &amp;lt; in.rsf uflag=y dflag=y alpha=45. titlsz=9 axissz=6 plotfat=0 titlefat=2 axisfat=2 plotcolup=VP_YELLOW plotcoldn=VP_RED axis=y axis1=y axis2=y axis3=y clip=0. pclip=100. gainstep=0.5+nx/256. bias=0. dclip=1. norm=y xc=1.5 zc=3 ratio=5. zmax= zmin= sz=6. label#= unit#= tpow=0 epow=0 gpow=1 title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;alpha=45.&#039;&#039;&#039; ||   || 	apparent angle in degrees, |alpha| &amp;lt; 89&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis1=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis2=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis3=y&#039;&#039;&#039; ||  [y/n] || 	plot axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axisfat=2&#039;&#039;&#039; ||   || 	axes fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axissz=6&#039;&#039;&#039; ||   || 	axes size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dclip=1.&#039;&#039;&#039; ||   || 	change the clip: clip *= dclip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;dflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot down side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;epow=0&#039;&#039;&#039; ||   || 	exponential gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+nx/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=1&#039;&#039;&#039; ||   || 	power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	normalize by the clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	data clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcoldn=VP_RED&#039;&#039;&#039; ||   || 	color of the lower side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcolup=VP_YELLOW&#039;&#039;&#039; ||   || 	color of the upper side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotfat=0&#039;&#039;&#039; ||   || 	line fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ratio=5.&#039;&#039;&#039; ||   || 	plot adjustment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;sz=6.&#039;&#039;&#039; ||   || 	vertical scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlefat=2&#039;&#039;&#039; ||   || 	title fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlsz=9&#039;&#039;&#039; ||   || 	title size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tpow=0&#039;&#039;&#039; ||   || 	time power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;uflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot upper side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xc=1.5&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zc=3&#039;&#039;&#039; ||   || 	lower left corner of the plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmax=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmin=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
==sfwiggle==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot data with wiggly traces. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwiggle &amp;lt; in.rsf xpos=xpos.rsf xmax= xmin= poly=n fatp=1 xmask=1 ymask=1 pclip=98. zplot=0.75 clip=0. seemean=n verb=n transp=n yreverse=n xreverse=n xpos= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip (estimated from pclip by default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;fatp=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=98.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;poly=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=n&#039;&#039;&#039; ||  [y/n] || 	if y, plot mean lines of traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;xmask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmax=&#039;&#039;&#039; ||   || 	maximum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmin=&#039;&#039;&#039; ||   || 	minimum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;xpos=&#039;&#039;&#039; ||   || 	optional header file with trace positions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ymask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zplot=0.75&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
=Plotting programs (development)=&lt;br /&gt;
==sfplsurf==&lt;br /&gt;
&amp;lt;tt&amp;gt;sfplsurf&amp;lt;/tt&amp;gt; utilizes PLplot&#039;s surface rendering capabilities. Output is dumped to stdout in VPLOT format, so it can easily be used in the same way as &amp;lt;tt&amp;gt;sfgrey&amp;lt;/tt&amp;gt; or other plotting programs. It also supports animation, if n3 &amp;gt; 1 in the input file. A SConstruct usage example can be found below. A [http://reproducibility.org/wikilocal/movies/sfplsurf_membrane.mpg movie of the output] is available as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# x &amp;amp; y dimensions&lt;br /&gt;
o1=-2&lt;br /&gt;
o2=-2&lt;br /&gt;
n1=41&lt;br /&gt;
n2=41&lt;br /&gt;
d1=0.1&lt;br /&gt;
d2=0.1&lt;br /&gt;
# z dimension&lt;br /&gt;
o3=-1&lt;br /&gt;
n3=21&lt;br /&gt;
d3=0.1&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;membrane&#039;,None,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    math o1=%g o2=%g n1=%d n2=%d d1=%g d2=%g&lt;br /&gt;
          o3=%g n3=%d d3=%g&lt;br /&gt;
          output=&amp;quot;x3*cos(x1*x1+x2*x2)*exp(-0.1*(x1*x1+x2*x2))&amp;quot;&lt;br /&gt;
    &#039;&#039;&#039; % (o1,o2,n1,n2,d1,d2,o3,n3,d3))&lt;br /&gt;
&lt;br /&gt;
Result(&#039;membrane&#039;,&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      plsurf title=&amp;quot;Membrane&amp;quot; mesh=n color=j&lt;br /&gt;
              minval=%g maxval=%g&lt;br /&gt;
      &#039;&#039;&#039; % (o3,o3 + d3*(n3-1)))&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=system/generic programs=&lt;br /&gt;
==sfremap1==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 1-D ENO interpolation. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfremap1 &amp;lt; in.rsf &amp;gt; out.rsf pattern=pattern.rsf n1=n1 d1=d1 o1=o1 order=3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=d1&#039;&#039;&#039; ||   || 	Output sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=n1&#039;&#039;&#039; ||   || 	Number of output samples&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=o1&#039;&#039;&#039; ||   || 	Output origin&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;order=3&#039;&#039;&#039; ||   || 	Interpolation order&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;pattern=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
To give an example of usage, we will create an input for &amp;lt;tt&amp;gt;sfremap1&amp;lt;/tt&amp;gt; with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=11 n2=11 d1=1 d2=1 o1=-5 o2=-5 output=&amp;quot;x1*x1+x2*x2&amp;quot; &amp;gt; inp2remap1.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Let us interpolate the data across both dimensions, then display it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt; inp2remap1.rsf sfremap1 n1=1001 d1=0.01 | sftransp | \&lt;br /&gt;
sfremap1 n1=1001 d1=0.01 | sftransp | sfgrey allpos=y | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The comparison with the uninterpolated data ( &amp;lt;tt&amp;gt;&amp;amp;lt; inp2remap1.rsf sfgrey allpos=y | sfpen&amp;lt;/tt&amp;gt; ) is quite telling.&lt;br /&gt;
&lt;br /&gt;
=system/seismic programs=&lt;br /&gt;
==sfstretch==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stretch of the time axis. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstretch &amp;lt; in.rsf &amp;gt; out.rsf datum=dat.rsf inv=n dens=1 v0= half=y delay= tdelay= hdelay= nout=dens*n1 extend=4 mute=0 maxstr=0 rule=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;datum=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;delay=&#039;&#039;&#039; ||   || 	time delay for rule=lmo&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dens=1&#039;&#039;&#039; ||   || 	axis stretching factor&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;extend=4&#039;&#039;&#039; ||   || 	trace extension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;half=y&#039;&#039;&#039; ||  [y/n] || 	if y, the second axis is half-offset instead of full offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;hdelay=&#039;&#039;&#039; ||   || 	offset delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;inv=n&#039;&#039;&#039; ||  [y/n] || 	if y, do inverse stretching&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxstr=0&#039;&#039;&#039; ||   || 	maximum stretch&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;mute=0&#039;&#039;&#039; ||   || 	tapering size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nout=dens*n1&#039;&#039;&#039; ||   || 	output axis length (if inv=n)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;rule=&#039;&#039;&#039; ||   || 	Stretch rule:&lt;br /&gt;
:n - normal moveout (nmostretch), default&lt;br /&gt;
:l - linear moveout (lmostretch)&lt;br /&gt;
:L - logarithmic stretch (logstretch)&lt;br /&gt;
:2 - t^2 stretch (t2stretch)&lt;br /&gt;
:c - t^2 chebyshev stretch (t2chebstretch)&lt;br /&gt;
:r - radial moveout (radstretch)&lt;br /&gt;
:d - datuming (datstretch)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;tdelay=&#039;&#039;&#039; ||   || 	time delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;v0=&#039;&#039;&#039; ||   || 	moveout velocity&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstretch rule=d&amp;lt;/tt&amp;gt; (aka &amp;lt;tt&amp;gt;sfdatstretch&amp;lt;/tt&amp;gt;) can be used to apply statics. Here is a synthetic example, courtesy of Alessandro Frigeri:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# generate a dataset with &#039;flat&#039; signals&lt;br /&gt;
sfmath n1=200 n2=100 output=&amp;quot;sin(0.5*x1)&amp;quot; type=float &amp;gt; scan.rsf&lt;br /&gt;
&lt;br /&gt;
# generate a sinusoidal elevation correction&lt;br /&gt;
sfmath n1=100 output=&amp;quot;3*sin(x1)&amp;quot; type=float &amp;gt; statics.rsf&lt;br /&gt;
&lt;br /&gt;
# apply statics, producing a &#039;wavy&#039; output.&lt;br /&gt;
sfstretch &amp;lt; scan.rsf &amp;gt; out.rsf datum=statics.rsf rule=d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/fomels programs=&lt;br /&gt;
==sfpick==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Automatic picking  from semblance-like panels. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpick &amp;lt; scn.rsf &amp;gt; pik.rsf vel0=o2 niter=100 an=1. gate=3 smooth=y rect#=(1,1,...) rect1=1 rect2=1 ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | rectN defines the size of the smoothing stencil in N-th dimension.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Theory in Appendix B of:&amp;lt;br&amp;gt;S. Fomel, 2009, &amp;lt;br&amp;gt;Velocity analysis using AB semblance: Geophysical Prospecting, v. 57, 311-321.&amp;lt;br&amp;gt;Reproducible version in RSFSRC/book/jsg/avo &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;an=1.&#039;&#039;&#039; ||   || 	axes anisotropy&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gate=3&#039;&#039;&#039; ||   || 	picking gate&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=100&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rect#=(1,1,...)&#039;&#039;&#039; ||   || 	smoothing radius on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;smooth=y&#039;&#039;&#039; ||  [y/n] || 	if apply smoothing&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vel0=o2&#039;&#039;&#039; ||   || 	surface velocity&lt;br /&gt;
|}&lt;br /&gt;
Short description of the algorithm:&lt;br /&gt;
# Start from the top (first time slice), pick an initial (source) point, evaluate all other points with the direct traveltime.&lt;br /&gt;
# At each grid point at the next level, find the traveltime to points at the previous level, add the traveltimes from the previous level, and select minimum. The search radius is limited by the aperture (gate= parameter in sfpick).&lt;br /&gt;
# Repeat step 2 until reaching the bottom.&lt;br /&gt;
# Pick the minimum traveltime at the bottom and track the ray back to the source by following the traveltime gradient direction.&lt;br /&gt;
# Postprocessing (smooth= parameter in sfpick): smooth the picked ray path using shaping regularization.&lt;br /&gt;
&lt;br /&gt;
The algorithm was discovered and rediscovered by many people. The best reference is probably &#039;&#039;V. Meshbey, E. Ragoza, D. Kosloff, U. Egozi, and D. Wexler, 2002, Three-dimensional Travel-time Calculation Based on Fermat&#039;s Principle: Pure and Applied Geophysics, v. 159, 1563-1582.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=user/ivlad programs=&lt;br /&gt;
==sfprep4plot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Resamples a 2-D dataset to the desired picture resolution, with antialias&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfprep4plot inp= out= verb=n h=none w=none unit= ppi= prar=y&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Only one of the h and w parameters needs to be specified.&amp;lt;br&amp;gt;If prar=n, no action will be taken on axis for which h/w was not specified&amp;lt;br&amp;gt;If prar=y and only one par (h or w) is specified, the picture will scale&amp;lt;br&amp;gt;along both axes until it is of the specified dimension.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;h=none&#039;&#039;&#039; ||   || 	output height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;inp=&#039;&#039;&#039; ||   || 	input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;out=&#039;&#039;&#039; ||   || 	output file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ppi=&#039;&#039;&#039; ||   || 	output resolution (px/in). Necessary when unit!=px&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;prar=y&#039;&#039;&#039; ||  [y/n] || 	if y, PReserve Aspect Ratio of input&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	unit of h and w. Can be: px(default), mm, cm, in&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	if y, print system commands, outputs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;w=none&#039;&#039;&#039; ||   || 	output width&lt;br /&gt;
|}&lt;br /&gt;
For a figure that does not need the aspect ratio preserved,&lt;br /&gt;
and needs to fill a 1280x1024 projector display:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=1280 h=1024 prar=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a print figure that has to fit in a 6x8in box&lt;br /&gt;
at a resolution of 250 dpi, preserving the aspect ratio:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=6 h=8 unit=in ppi=250&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A comparison of images before and after the application of &amp;lt;tt&amp;gt;sfprep4plot&amp;lt;/tt&amp;gt;, courtesy of Joachim Mispel, is shown below:&lt;br /&gt;
&lt;br /&gt;
[[Image:sf_prep4plot.jpg]]&lt;br /&gt;
&lt;br /&gt;
==sfcsv2rsf==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a delimited-text ASCII file to RSF binary floating point or int.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcsv2rsf help=n delimiter=, dtype=float verb=n debug=n trunc=n o1=0. o2=0. d1=1. d2=1. unit1=unknown unit2=unknown label1=unknown label2=unknown&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Zeros will be added if number of elements is not the same in each row.&amp;lt;br&amp;gt;n1 and n2 are computed automatically. For consistency with sfdisfil and &amp;lt;br&amp;gt;sfmatmult, output is C-style order (row-first), i.e. rows in input file &amp;lt;br&amp;gt;become dimension-1 columns in output. Output encoding is native.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d2=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;debug=n&#039;&#039;&#039; ||  [y/n] || 	Extra verbosity for debugging&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;delimiter=,&#039;&#039;&#039; ||   || 	Separator between values in input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;dtype=float&#039;&#039;&#039; ||   || 	Input type&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;help=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o2=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trunc=n&#039;&#039;&#039; ||  [y/n] || 	Truncate or add zeros if nr elems in rows differs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Whether to echo n1, n2, infill/truncation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A small usage example follow below. First, create an input file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ echo -e &#039;5,6,8,9.2\n11,124,5,0,1&#039; | tee file.csv&lt;br /&gt;
5,6,8,9.2&lt;br /&gt;
11,124,5,0,1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may notice that the number of values in each row is different.&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;tt&amp;gt;sfcsv2rsf&amp;lt;/tt&amp;gt;. Notice that no options are needed. By default, zeros will be appended to make the rows equal length:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf &amp;gt; junk.rsf ; sfdisfil &amp;lt; junk.rsf &lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that sfdisfil displays in column order (i.e. matrix is transposed if the number of rows is right). The dimensions of the file are actually transposed on disk:&lt;br /&gt;
&lt;br /&gt;
$ sfin junk.rsf&lt;br /&gt;
junk.rsf:&lt;br /&gt;
    in=&amp;quot;/data/path/junk.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          unit1=&amp;quot;unknown&amp;quot; &lt;br /&gt;
    n2=2           d2=1           o2=0          unit2=&amp;quot;unknown&amp;quot; &lt;br /&gt;
	10 elements 40 bytes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may want to run the output through &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt;, depending on your needs. However, if creating an input for &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt;, this will not be necessary, because &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt; is made to work with matrices that are displayed with &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt;, and takes as input a transpose matrix.&lt;br /&gt;
&lt;br /&gt;
Pipes can be used, of course, to skip the creation of intermediary files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf | sfdisfil&lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that since this program does not need any arguments (just stdin and stdout), when called with no arguments it will not display the man page. In order to consult the automatically generated documentation, you need to pass the option &amp;lt;tt&amp;gt;help=y&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
=user/jennings programs=&lt;br /&gt;
==sfsizes==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display the size of RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsizes files=y human=n file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Prints the element size, number of elements, and number of bytes&amp;lt;br&amp;gt;for a list of RSF files.  Non-RSF files are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;files=y&#039;&#039;&#039; ||  [y/n] || 	If y, print size of each file.  If n, print only total.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;human=n&#039;&#039;&#039; ||  [y/n] || 	If y, print human-readable file size.  If n, print byte count.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This program computes the &amp;quot;theoretical&amp;quot; size in bytes of the data fork of RSF files.  The actual space occupied on disk may be different and machine dependent due to disk blocking factors, etc.  This theoretical array size should be reproducible.  It is also fast because the program only reads the RSF headers files, not the actual data.&lt;br /&gt;
&lt;br /&gt;
For example, to get the total size of all RSF files in a directory, in human readable format, without listing each file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will also work because sfsizes simply skips any non-RSF file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sffiglist==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Compare Vplot files in Fig and Lock directories&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffiglist figdir= lockdir= list= show=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |&lt;br /&gt;
Parameter &#039;&#039;&#039;figdir&#039;&#039;&#039; is path to Fig directory, default is ./Fig.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;lockdir&#039;&#039;&#039; is path to Lock directory:&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is not in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFALTFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;list&#039;&#039;&#039; controls files to list, default is all.&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;show&#039;&#039;&#039; controls files to flip with sfpen, default is none.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = none (No files, print only summary.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = diff (Files that are different, determined by sfvplotdiff.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = miss (Files missing from figdir or lockdir, and different files.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = all (All files.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;File list codes:&lt;br /&gt;
&amp;lt;br&amp;gt;space   indicates files that are the same.&lt;br /&gt;
&amp;lt;br&amp;gt;  -     indicates file in lockdir that is missing from figdir.&lt;br /&gt;
&amp;lt;br&amp;gt;  +     indicates extra file in figdir that is missing from lockdir.&lt;br /&gt;
&amp;lt;br&amp;gt;number  is return code from sfvplotdiff indicating different files.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;figdir=&#039;&#039;&#039; ||   || 	fig directory, default = ./Fig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;list=&#039;&#039;&#039; ||   || 	how much to list [none,diff,miss,all], default = all&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;lockdir=&#039;&#039;&#039; ||   || 	lock directory, default = lock counterpart of figdir&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;show=&#039;&#039;&#039; ||   || 	how much to show [none,diff,miss,all], default = none&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tool lists Vplot files in &amp;quot;Fig&amp;quot; and &amp;quot;Lock&amp;quot; directories and compares them using sfvplotdiff.&lt;br /&gt;
&lt;br /&gt;
The Fig directory defaults to ./Fig and the Lock directory defaults to the  &lt;br /&gt;
corresponding directory where &amp;quot;scons lock&amp;quot; puts things, but either  &lt;br /&gt;
default can be overridden with the user parameters &#039;&#039;&#039;figdir&#039;&#039;&#039; and &#039;&#039;&#039;lockdir&#039;&#039;&#039; so that, for example,  &lt;br /&gt;
files in two different Fig directories can be compared.&lt;br /&gt;
&lt;br /&gt;
The default for the Lock directory has some logic to look in $RSFFIGS  &lt;br /&gt;
when Fig is in $RSFSRC/book, or to look in $RSFALTFIGS when Fig is not  &lt;br /&gt;
in $RSFSRC/book because I like to keep two different Lock directories:  &lt;br /&gt;
one for stuff in book and another for my own stuff that is not in  &lt;br /&gt;
book.  However, I tried to make the code default to reasonable things  &lt;br /&gt;
if any of these environment variables are not defined.&lt;br /&gt;
&lt;br /&gt;
The tool gives a summary count of files that are the same, files that  &lt;br /&gt;
are different, files in Fig that are missing from Lock, and files in  &lt;br /&gt;
Lock that are missing from Fig.&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;list&#039;&#039;&#039; (default=all) and &#039;&#039;&#039;show&#039;&#039;&#039; (default=none) control which files are listed or &amp;quot;flipped&amp;quot; with sfpen.  The file listing indicates which files are the same, which are different, and which are missing from Fig or Lock.&lt;br /&gt;
&lt;br /&gt;
For example, to list all the Vplot files in Fig and Lock:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To list all Vplot files and flip only files that are different:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all show=diff&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/psava programs=&lt;br /&gt;
&lt;br /&gt;
==sfawefd2d==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | acoustic time-domain FD modeling &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfawefd &amp;lt; Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf &amp;gt; Fdat.rsf den=Fden.rsf ompchunk=1 ompnth=0 verb=n snap=n free=n expl=n jdata=1 jsnap=nt nq1=sf_n(a1) nq2=sf_n(a2) oq1=sf_o(a1) oq2=sf_o(a2)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;den=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;expl=n&#039;&#039;&#039; ||  [y/n] || 	&amp;quot;exploding reflector&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;free=n&#039;&#039;&#039; ||  [y/n] || 	free surface flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jdata=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jsnap=nt&#039;&#039;&#039; ||   || 	save wavefield every *jsnap* time steps&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq1=sf_n(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq2=sf_n(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   || 	OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   || 	OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq1=sf_o(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq2=sf_o(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rec=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;snap=n&#039;&#039;&#039; ||  [y/n] || 	wavefield snapshots flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;sou=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;vel=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;wfl=&#039;&#039;&#039; ||   || 	auxiliary output file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
An example will be demonstrated below on a model with nx=nz=200, dx=dz=4m (size: 800x800m). There are two layers: the first one is 100x200 samples in (z,x) and the velocity is 1500m/s; the second layer has the same dimension and the velocity is 3000m/s. Density is set to 1 for the whole grid. A source and a receiver are co-located at x=400 and z=100. The full wavefield for the entire model aperture will be saved every 10th time step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
# Velocity model:&lt;br /&gt;
sfspike &amp;gt;Fvel.rsf mag=1500,3000 nsp=2 k1=1,101 l1=100,200 d1=4 d2=4 \&lt;br /&gt;
label1=z label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Density model:&lt;br /&gt;
sfspike &amp;gt;Fden.rsf mag=1 nsp=1 k1=1 l1=200 d1=4 d2=4 label1=z \&lt;br /&gt;
label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Source position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Fsou.rsf&lt;br /&gt;
&lt;br /&gt;
# Receiver position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Frec.rsf&lt;br /&gt;
&lt;br /&gt;
# Source wavelet:&lt;br /&gt;
sfspike nsp=1 n1=2000 d1=0.0005 k1=200 | sfricker1 frequency=20 |\&lt;br /&gt;
sftransp &amp;gt;Fwav.rsf&lt;br /&gt;
&lt;br /&gt;
# Creating data at specified receiver + saving full wavefield every 10th step:&lt;br /&gt;
sfawefd2d &amp;lt;Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf \&lt;br /&gt;
den=Fden.rsf &amp;gt;Fdat.rsf verb=y free=y expl=y snap=y dabc=y jdata=1 jsnap=10&lt;br /&gt;
echo &#039;label1=z unit1=m label2=x unit2=m&#039; &amp;gt;&amp;gt; Fwfl.rsf&lt;br /&gt;
&lt;br /&gt;
# View the wavefield movie:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfgrey gainpanel=a pclip=99 color=j scalebar=y | sfpen &lt;br /&gt;
&lt;br /&gt;
# View a wavefield snapshot:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfwindow f3=80 n3=1 |\&lt;br /&gt;
sfgrey pclip=99 color=j title=&#039;snapshot at t=0.4s&#039; |\&lt;br /&gt;
sfpen &lt;br /&gt;
&lt;br /&gt;
# View the data recorded at receiver:&lt;br /&gt;
&amp;lt;Fdat.rsf sfwindow |\&lt;br /&gt;
sfgraph title=&#039;Data recorded at receiver&#039; unit2=&#039;&#039; label2=amplitude |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:sfawefd_wfld.jpg|frame|center|sfawefd wavefield screenshot]]&lt;br /&gt;
[[Image:sfawefd_dat.png|frame|center|sfawefd data screenshot]]&lt;br /&gt;
&lt;br /&gt;
Attention: time steps that are too large can result in numerical instability.&lt;br /&gt;
&lt;br /&gt;
==sfsrmig3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 3-D S/R migration with extended SSF&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsrmig3 slo=Fs_s.rsf sls=Fs_r.rsf &amp;lt; Fw_s.rsf rwf=Fw_r.rsf &amp;gt; Fi.rsf cig=Fc.rsf ompchunk=1 ompnth=0 verb=y eps=0.01 twoway=n nrmax=1 dtmax=0.004 pmx=0 pmy=0 tmx=0 tmy=0 vpvs=1. hsym=n nht=1 oht=0 dht=0.1 nht=1 oht=0 dht=0.1 hsym=n nhh=1 ohh=0 dhh=0.1 nha=180 oha=0 dha=2.0 nhb=180 ohb=0 dhb=2.0 itype=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;cig=&#039;&#039;&#039; ||   ||     auxiliary output file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dha=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhb=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhh=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dht=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dtmax=0.004&#039;&#039;&#039; ||   ||      max time error&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;eps=0.01&#039;&#039;&#039; ||   ||         stability parameter&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;hsym=n&#039;&#039;&#039; ||  [y/n] ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;itype=&#039;&#039;&#039; ||   ||   imaging condition type&lt;br /&gt;
:o = zero lag (default)&lt;br /&gt;
:e = extended&lt;br /&gt;
:x = space-lags&lt;br /&gt;
:h = space-lags magnitude&lt;br /&gt;
:t = time-lag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nha=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhb=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhh=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nht=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nrmax=1&#039;&#039;&#039; ||   ||  max number of refs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oha=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohb=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohh=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oht=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   ||       OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   ||         OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmx=0&#039;&#039;&#039; ||   ||    padding on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmy=0&#039;&#039;&#039; ||   ||    padding on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rwf=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;slo=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;sls=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmx=0&#039;&#039;&#039; ||   ||    taper on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmy=0&#039;&#039;&#039; ||   ||    taper on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;twoway=n&#039;&#039;&#039; ||  [y/n] ||    two-way traveltime&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=y&#039;&#039;&#039; ||  [y/n] ||      verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vpvs=1.&#039;&#039;&#039; ||   ||  Vp/Vs ratio&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This program performs 3-D and 2-D shot-record (a.k.a. shot-profile) migration with an extended Split-Step Fourier (SSF) extrapolator with multiple reference velocities (hence &amp;quot;extended&amp;quot;). It takes as input a shot wavefield (&amp;lt;tt&amp;gt;stdin&amp;lt;/tt&amp;gt;), receiver wavefield (&amp;lt;tt&amp;gt;rwf=&amp;lt;/tt&amp;gt;) and slowness model (&amp;lt;tt&amp;gt;slo=&amp;lt;/tt&amp;gt;). Outputs are an image (&amp;lt;tt&amp;gt;stdout&amp;lt;/tt&amp;gt;) and a cube of Common Image Gathers (&amp;lt;tt&amp;gt;cig=&amp;lt;/tt&amp;gt;). An important parameter is &amp;lt;tt&amp;gt;nrmax&amp;lt;/tt&amp;gt;, the number of reference velocities. Its default value is 1, but for reasonable results it should be 5 or so. It is also good to specify nonzero taper values (&amp;lt;tt&amp;gt;tmx&amp;lt;/tt&amp;gt; and, for 3-D, &amp;lt;tt&amp;gt;tmy&amp;lt;/tt&amp;gt; as well). The values of padding parameters &amp;lt;tt&amp;gt;pmx&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;pmy&amp;lt;/tt&amp;gt; are split in two by the program, i.e. if your data x axis is 501-points long, specify pmx=11 to get a value of 512 that will result in fast Fourier Transforms. &lt;br /&gt;
&lt;br /&gt;
The program will also migrate converted-wave data if a file with the S-wave slowness model (&amp;lt;tt&amp;gt;sls=&amp;lt;/tt&amp;gt;) is provided.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; parameter is only used when &amp;lt;tt&amp;gt;itype=h&amp;lt;/tt&amp;gt;. Do not specify a &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; value unless you know really well what you are doing.&lt;br /&gt;
&lt;br /&gt;
===Usage example===&lt;br /&gt;
The commands below, slightly modified from [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/data/sigsbee/ptest/SConstruct?revision=3993&amp;amp;view=markup RSFSRC/book/data/sigsbee/ptest], show how to prepare the [http://www.reproducibility.org/RSF/book/data/sigsbee Sigsbee 2A] data and velocity for migration.&lt;br /&gt;
&lt;br /&gt;
Convert input data (shots) from SEG-Y to RSF:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_nfs.segy tfile=tdata.rsf hfile=/dev/null bfile=/dev/null &amp;gt; ddata.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Convert trace headers to float (required by &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; tdata.rsf sfdd type=float &amp;gt; trchdr.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Shot positions:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;fldr + 10925/150&amp;quot; | sfwindow squeeze=y &amp;gt; tsi.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Extract offset positions from the trace header files, eliminate length-1 axis, scale, create a header for binning (required by &amp;lt;tt&amp;gt;sfintbin&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;offset&amp;quot; |\&lt;br /&gt;
sfwindow squeeze=y |\&lt;br /&gt;
sfmath output=&amp;quot;input/75&amp;quot; |\&lt;br /&gt;
sfcat axis=2 space=n tsi.rsf |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfdd type=int &amp;gt; tos.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Binning and muting:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; ddata.rsf sfintbin head=tos.rsf xkey=0 ykey=1 |\&lt;br /&gt;
sfput label1=Time unit1=s d2=0.075 o2=0.0 label2=hx d3=0.150 o3=10.925 label3=sx |\&lt;br /&gt;
sfmutter half=false t0=1.0 v0=6.0 |\&lt;br /&gt;
sfput d2=0.02286 o2=0 unit2=km d3=0.04572 o3=3.32994 unit3=km &amp;gt; shots.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Keeping only 20 shots so that this 1-node job will not take forever, FFT-ing, decimating frequency slices (same as shortening the time axis), and creating y and hy axes of length 1:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; shots.rsf sfwindow n3=20 f3=10 j3=20 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfspray axis=3 n=1 o=0 d=1 label=hy |\&lt;br /&gt;
sfspray axis=5 n=1 o=0 d=1 label=sy &amp;gt; rfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The dimensions of the cube thus created are:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin rfft.rsf trail=n&lt;br /&gt;
rfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;Frequency&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n2=348         d2=0.02286     o2=0          label2=&amp;quot;hx&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=1           d3=1           o3=0          label3=&amp;quot;hy&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
    n4=20          d4=0.9144      o4=3.78714    label4=&amp;quot;sx&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        1392000 elements 11136000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create the source wavelet (limited to the same frequency band as the data) and Fourier transform it:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike k1=1 n1=1500 d1=0.008 |\&lt;br /&gt;
sfbandpass flo=15 fhi=25 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfput label1=freq &amp;gt; sfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a frequency-domain wavelet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin sfft.rsf&lt;br /&gt;
sfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/sfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;freq&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
        200 elements 1600 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create &amp;quot;synched&amp;quot; source and receiver wavefields with &amp;lt;tt&amp;gt;srsyn&amp;lt;/tt&amp;gt; from wavelet and data frequency slices. Basically both the receiver and shot frequency slices are &amp;quot;placed&amp;quot; at the right location and padded with zeros up to the dimension of the x axis specified below.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rfft.rsf sfsrsyn nx=1067 dx=0.02286 ox=3.05562 wav=sfft.rsf swf=swav.rsf &amp;gt; rwav.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates frequency slices ready for migration for both source and receiver, only axis 1 (frequency) must become axis 3, for both datasets:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; swav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; stra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rwav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; rtra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a surface receiver wavefield ready for input to migration. Axis 4 is shot number. The values of axis 4 are arbitrary because each shot has been padded with zeros so that it covers the entire velocity model. Therefore the aperture of the downward continuation for each shot will be as large as the survey.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin trail=n rtra.rsf&lt;br /&gt;
rtra.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rtra.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=200         d3=0.25        o3=1          label3=&amp;quot;w&amp;quot; unit3=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n4=20          d4=1           o4=0          label4=&amp;quot;e&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        4268000 elements 34144000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Convert the velocity model from SEG-Y to RSF, decimate, convert from feet to km, transpose, convert to slowness and insert an additional axis:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_migvel.sgy tfile=/dev/null hfile=/dev/null bfile=/dev/null |\&lt;br /&gt;
sfput o1=0 d1=0.00762 label1=z unit1=km o2=3.05562 d2=0.01143 label2=x unit2=km |\&lt;br /&gt;
sfwindow j1=4 j2=2 |\&lt;br /&gt;
sfscale rscale=0.0003048 |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfmath output=&amp;quot;1/input&amp;quot; |\&lt;br /&gt;
sfspray axis=2 n=1 d=1 o=0 |\&lt;br /&gt;
sfput label2=y &amp;gt; slow.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a slowness file ready for input to migration, with an x axis identical to the x axis of the wavefield files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin slow.rsf&lt;br /&gt;
slow.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slow.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, the migration command (for a 4-processor machine, hence the &amp;lt;tt&amp;gt;ompnth&amp;lt;/tt&amp;gt; value). We choose not to compute any image gathers (&amp;lt;tt&amp;gt;itype=o&amp;lt;/tt&amp;gt;), but due to the construction of the program we still have to explicitly assign the &amp;lt;tt&amp;gt;cig&amp;lt;/tt&amp;gt; tag, or else a RSF file with the name of the tag and no rsf extension will be created:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; stra.rsf sfsrmig3 nrmax=20 dtmax=5e-05 eps=0.01 verb=y ompnth=4 \&lt;br /&gt;
tmx=16 rwf=rtra.rsf slo=slow.rsf itype=o cig=/dev/null &amp;gt; img.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The migration of 20 shots takes approximately 3 hours on a 4-processor machine (1 shot=9 minutes). Without the frequency slice decimation by a factor of 3 and the depth axis decimation by a factor of 4, it would have taken twelve times as much. The resulting image has a y axis of length 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin img.rsf trail=n&lt;br /&gt;
img.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/img.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To properly visualize the image, we need to eliminate the axis of length 1, then transpose the x and z axes to their natural position:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;img.rsf sfwindow squeeze=y | sftransp | sfgrey &amp;gt; img.vpl&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=SEPlib_to_m8r_dictionary&amp;diff=2428</id>
		<title>SEPlib to m8r dictionary</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=SEPlib_to_m8r_dictionary&amp;diff=2428"/>
		<updated>2012-11-08T03:06:09Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Programs */ Wedge&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://sep.stanford.edu/doku.php?id=sep:software:seplib SEPlib] is a software package for seismic data processing developed at the [http://sep.stanford.edu/doku.php Stanford Exploration Project]. The dictionary below is intended for SEPlib users who are interested in either using Madagascar (m8r) or in finding out which algorithms/utilities are present in m8r, but not in SEPlib. &lt;br /&gt;
&lt;br /&gt;
A m8r program, or a chain of m8r programs, will be considered equivalent to a SEPlib counterpart only if it has at least all the capabilities of its SEPlib counterpart. The fact that two of [http://sepwww.stanford.edu/data/media/public/sep/prof/index.html Claerbout&#039;s books] (&#039;&#039;Basic Earth Imaging&#039;&#039; and &#039;&#039;Imaging Estimation by Example&#039;&#039;) and several SEP report articles have been [[Reproducible_Documents | reproduced with Madagascar]] shows that at least a significant subset of SEPlib is fully translatable. Individual programs may not be equivalent option-for-option. Like Lego blocks, they come together only when data flow examples are created from them, and such flows can certainly made fully equivalent even if the &amp;quot;building blocks&amp;quot; may differ slightly.&lt;br /&gt;
&lt;br /&gt;
The starting point of the list below was the list of manual pages in SEPlib 6.5.3 (&amp;lt;tt&amp;gt;docs/man/man{1,3}/*.mn&amp;lt;/tt&amp;gt; in the source code distribution). For programs, those files starting with a capital leter (the SEPlib convention for program names) were considered.&lt;br /&gt;
&lt;br /&gt;
==Programs==&lt;br /&gt;
* 5dFFT&lt;br /&gt;
* Agc: [http://www.ahay.org/RSF/sfagc.html sfagc]&lt;br /&gt;
* AMO: [http://www.ahay.org/RSF/sffkamo.html sffkamo]&lt;br /&gt;
* Aniso2d&lt;br /&gt;
* Attr3dhead: [http://www.ahay.org/RSF/headerattr.html sfheaderattr]&lt;br /&gt;
* Attr: [http://www.ahay.org/RSF/sfattr.html sfattr]&lt;br /&gt;
* Balance&lt;br /&gt;
* Box: [http://www.ahay.org/RSF/sfbox.html sfbox]&lt;br /&gt;
* Byte: [http://www.ahay.org/RSF/sfgrey.html sfgrey] (with appropriate options -- what are those?)&lt;br /&gt;
* CAM: [http://www.ahay.org/RSF/sfcamig3.html sfcamig3]&lt;br /&gt;
* Cfft: [http://www.ahay.org/RSF/sffft3.html sffft3]&lt;br /&gt;
* Contour: [http://www.ahay.org/RSF/sfcontour.html sfcontour]&lt;br /&gt;
* Cp3d&lt;br /&gt;
* Cp: [http://www.ahay.org/RSF/sfcp.html sfcp]&lt;br /&gt;
* Create3d&lt;br /&gt;
* Cubeplot: [http://www.ahay.org/RSF/sfgrey3.html sfgrey3]: &amp;lt;tt&amp;gt;Cubeplot out=file.H &amp;gt;/dev/null&amp;lt;/tt&amp;gt; is equivalent to &amp;lt;tt&amp;gt;sfgrey3 &amp;gt; file.rsf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Cubeplot | Tube&amp;lt;/tt&amp;gt; is equivalent to &amp;lt;tt&amp;gt;sfgrey3 | sfpen&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Dd: see Sdd&lt;br /&gt;
* Dip_azim&lt;br /&gt;
* Dip: [http://www.ahay.org/RSF/sfdip.html sfdip]&lt;br /&gt;
* Dis3dhead&lt;br /&gt;
* Disfil: [http://www.ahay.org/RSF/sfdisfil.html sfdisfil]&lt;br /&gt;
* Dots: [http://www.ahay.org/RSF/sfdots.html sfdots]&lt;br /&gt;
* Edit&lt;br /&gt;
* Energy&lt;br /&gt;
* Envelope: [http://www.ahay.org/RSF/sfenvelope.html sfenvelope]&lt;br /&gt;
* Fdmod2: [http://www.ahay.org/RSF/sfawefd2d.html sfawefd2d]&lt;br /&gt;
* Filter: [http://www.ahay.org/RSF/sfconv.html sfconv]&lt;br /&gt;
* FMeikonal: [http://www.ahay.org/RSF/sfeikonal.html sfeikonal]&lt;br /&gt;
* Fold3d&lt;br /&gt;
* Ft3d&lt;br /&gt;
* Ftplot&lt;br /&gt;
* Fx2d&lt;br /&gt;
* Gauss&lt;br /&gt;
* Get: [http://www.ahay.org/RSF/sfget.html sfget]&lt;br /&gt;
* Gfgradz&lt;br /&gt;
* Graph: [http://www.ahay.org/RSF/sfgraph.html sfgraph]&lt;br /&gt;
* Grey: [http://www.ahay.org/RSF/sfgrey.html sfgrey]: &amp;lt;tt&amp;gt;Grey out=file.H &amp;gt;/dev/null&amp;lt;/tt&amp;gt; is equivalent to &amp;lt;tt&amp;gt;sfgrey &amp;gt; file.rsf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Grey | Tube&amp;lt;/tt&amp;gt; is equivalent to &amp;lt;tt&amp;gt;sfgrey | sfpen&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Grid_fold&lt;br /&gt;
* Halfint: [http://www.ahay.org/RSF/sfhalfint.html sfhalfint]&lt;br /&gt;
* Headermath: [http://www.ahay.org/RSF/sfheadermath.html sfheadermath]&lt;br /&gt;
* Helicon: [http://www.ahay.org/RSF/sfhelicon.html sfhelicon]&lt;br /&gt;
* Histogram: [http://www.ahay.org/RSF/sfhistogram.html sfhistogram]&lt;br /&gt;
* Hwt3d: [http://www.ahay.org/RSF/sfhwt3d.html sfhwt3d]&lt;br /&gt;
* Hypint: [http://www.ahay.org/RSF/sfveltran.html sfveltran]&lt;br /&gt;
* Hypmovie&lt;br /&gt;
* Hypsum&lt;br /&gt;
* In: [http://www.ahay.org/RSF/sfin.html sfin]&lt;br /&gt;
* In3d&lt;br /&gt;
* Interleave: [http://www.ahay.org/RSF/sfinterleave.html sfinterleave]&lt;br /&gt;
* Interp&lt;br /&gt;
* Iso2d&lt;br /&gt;
* Kirch_2d_depth&lt;br /&gt;
* Kirmod3d: [http://www.ahay.org/RSF/sfkirmod3.html sfkirmod3]&lt;br /&gt;
* Log&lt;br /&gt;
* Lpfilt: [http://www.ahay.org/RSF/sfbandpass.html sfbandpass]&lt;br /&gt;
* Marine_geom3d&lt;br /&gt;
* Math: [http://www.ahay.org/RSF/sfmath.html sfmath]&lt;br /&gt;
* MCvfit&lt;br /&gt;
* Median: [http://www.ahay.org/RSF/sfmedian.html sfmedian]&lt;br /&gt;
* Merge: [http://www.ahay.org/RSF/sfmerge.html sfmerge]&lt;br /&gt;
* Miss: [http://www.ahay.org/RSF/sfmiss.html sfmiss]&lt;br /&gt;
* MTTmaps&lt;br /&gt;
* Mute3d&lt;br /&gt;
* Mute: [http://www.ahay.org/RSF/sfmutter.html sfmutter]&lt;br /&gt;
* Mv3d&lt;br /&gt;
* Mv: [http://www.ahay.org/RSF/sfmv.html sfmv]&lt;br /&gt;
* Nmo3d&lt;br /&gt;
* Noise: [http://www.ahay.org/RSF/sfnoise.html sfnoise]&lt;br /&gt;
* OFF2ANG: [http://www.ahay.org/RSF/sfradon.html sfradon] or [http://www.ahay.org/RSF/sfslant.html sfslant], followed by [http://www.ahay.org/RSF/sftan2ang.html sftan2ang].&lt;br /&gt;
* Operplot&lt;br /&gt;
* Overlay&lt;br /&gt;
* Pad: [http://www.ahay.org/RSF/sfpad.html sfpad] for padding with zeros, or [http://www.ahay.org/RSF/sfspray.html sfspray] for extending with the last value. Using sfspray directly will result in extending over an additional axis. To have an actual equivalent to Pad with extend option (extension across the same axis), sfspray can be used together with sfcat, i.e.: &amp;lt;tt&amp;gt;&amp;lt; inp.rsf sfwindow f2=-1 | sfspray axis=2 n=10 | sfcat axis=2 order=2,1 inp.rsf &amp;gt; out.rsf&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Pef: [http://www.ahay.org/RSF/sfpef.html sfpef]&lt;br /&gt;
* Phase: [http://www.ahay.org/RSF/sfsrmig3.html sfsrmig3] or [http://www.ahay.org/RSF/sfcamig3.html sfcamig3]&lt;br /&gt;
* Reshape&lt;br /&gt;
* Reverse: [http://www.ahay.org/RSF/sfreverse.html sfreverse]&lt;br /&gt;
* Rickmovie&lt;br /&gt;
* Ricksep&lt;br /&gt;
* Rm3d&lt;br /&gt;
* Rm: [http://www.ahay.org/RSF/sfrm.html sfrm]&lt;br /&gt;
* Scale: [http://www.ahay.org/RSF/sfscale.html sfscale]&lt;br /&gt;
* Scat3d&lt;br /&gt;
* Scat&lt;br /&gt;
* Sdd: [http://www.ahay.org/RSF/sfdd.html sfdd], with option &amp;lt;tt&amp;gt;type=&amp;lt;/tt&amp;gt; controlling the output (instead of &amp;lt;tt&amp;gt;esize=&amp;lt;/tt&amp;gt;)&lt;br /&gt;
* Segy2sep: [http://www.ahay.org/RSF/sfsegyread.html sfsegyread]&lt;br /&gt;
* Seis_vel&lt;br /&gt;
* Sep2segy: [http://www.ahay.org/RSF/sfsegywrite.html sfsegywrite]&lt;br /&gt;
* Sep2su: [http://www.ahay.org/RSF/sfsegywrite.html sfsuwrite, aka sfsegywrite su=y]&lt;br /&gt;
* Smooth: [http://www.ahay.org/RSF/sfsmooth.html sfsmooth]&lt;br /&gt;
* Spectra: [http://www.ahay.org/RSF/sfspectra.html sfspectra]&lt;br /&gt;
* Spike: [http://www.ahay.org/RSF/sfspike.html sfspike]&lt;br /&gt;
* SRM&lt;br /&gt;
* Stack3d&lt;br /&gt;
* Stolt: [http://www.ahay.org/RSF/sfstolt.html sfstolt]&lt;br /&gt;
* Stretch: [http://www.ahay.org/RSF/sfstretch.html sfstretch]&lt;br /&gt;
* Su2sep: [http://www.ahay.org/RSF/sfsegyread.html sfsuread, aka sfsegyread su=y]&lt;br /&gt;
* Surface&lt;br /&gt;
* Synch3d&lt;br /&gt;
* Ta2vplot: [http://ahay.org/RSF/sfgrey.html sfgrey]&lt;br /&gt;
* Thplot: [http://ahay.org/RSF/sfthplot.html sfthplot]&lt;br /&gt;
* Tpow: [http://www.ahay.org/RSF/sftpow.html sftpow]&lt;br /&gt;
* Transf&lt;br /&gt;
* Transp: [http://www.ahay.org/RSF/sftransp.html sftransp]&lt;br /&gt;
* Trcamp&lt;br /&gt;
* Tube: sfpen&lt;br /&gt;
* Vconvert&lt;br /&gt;
* Velan3d&lt;br /&gt;
* Velan: [http://www.ahay.org/RSF/sfvscan.html sfvscan]&lt;br /&gt;
* Vel:  [http://www.ahay.org/RSF/sfmakevel.html sfmakevel]&lt;br /&gt;
* Wavelet&lt;br /&gt;
* Wedge: [http://www.ahay.org/RSF/sfspray.html sfspray]: &amp;lt;tt&amp;gt;Wedge axis= nn= oo= dd=&amp;lt;/tt&amp;gt; is equivalent to &amp;lt;tt&amp;gt;sfspray axis= n= o= d=&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Wiggle: [http://www.ahay.org/RSF/sfwiggle.html sfwiggle]&lt;br /&gt;
* Window3d&lt;br /&gt;
* Window_key: [http://www.ahay.org/RSF/sfheaderwindow.html sfheaderwindow]&lt;br /&gt;
* Window: [http://www.ahay.org/RSF/sfwindow.html sfwindow]&lt;br /&gt;
&lt;br /&gt;
==Library procedures==&lt;br /&gt;
* adj_mod&lt;br /&gt;
* alloc&lt;br /&gt;
* array&lt;br /&gt;
* autocorr&lt;br /&gt;
* auxclose&lt;br /&gt;
* auxpar&lt;br /&gt;
* auxputch&lt;br /&gt;
* auxputhead&lt;br /&gt;
* binpull1&lt;br /&gt;
* binpull2&lt;br /&gt;
* bound&lt;br /&gt;
* boxconv&lt;br /&gt;
* box&lt;br /&gt;
* broyden_mod&lt;br /&gt;
* burg2&lt;br /&gt;
* burg&lt;br /&gt;
* butter&lt;br /&gt;
* c2h&lt;br /&gt;
* cadd&lt;br /&gt;
* cartesian&lt;br /&gt;
* causint&lt;br /&gt;
* cdiv&lt;br /&gt;
* cdoubint&lt;br /&gt;
* cdstep&lt;br /&gt;
* cefft&lt;br /&gt;
* cent&lt;br /&gt;
* cexp&lt;br /&gt;
* cgmeth&lt;br /&gt;
* cgstep&lt;br /&gt;
* chain&lt;br /&gt;
* ciexp&lt;br /&gt;
* cinv&lt;br /&gt;
* clog&lt;br /&gt;
* cmplx&lt;br /&gt;
* cmult&lt;br /&gt;
* cneg&lt;br /&gt;
* compress&lt;br /&gt;
* conjg&lt;br /&gt;
* conjgrad&lt;br /&gt;
* conv&lt;br /&gt;
* copy_data_pointer&lt;br /&gt;
* copy_history&lt;br /&gt;
* createhelix&lt;br /&gt;
* createmshelix&lt;br /&gt;
* createnhelix&lt;br /&gt;
* cross_wilson&lt;br /&gt;
* csmult&lt;br /&gt;
* cspow&lt;br /&gt;
* csqrt&lt;br /&gt;
* csub&lt;br /&gt;
* cvfft&lt;br /&gt;
* datapath&lt;br /&gt;
* ddot&lt;br /&gt;
* doc&lt;br /&gt;
* dottest&lt;br /&gt;
* energy&lt;br /&gt;
* evaluate_expression&lt;br /&gt;
* fastmarch&lt;br /&gt;
* fetch&lt;br /&gt;
* finish_susep&lt;br /&gt;
* fold&lt;br /&gt;
* fullnm&lt;br /&gt;
* gauss&lt;br /&gt;
* getch_add_string&lt;br /&gt;
* getch&lt;br /&gt;
* h2c&lt;br /&gt;
* halfdifa&lt;br /&gt;
* hclose&lt;br /&gt;
* hconest&lt;br /&gt;
* helderiv&lt;br /&gt;
* heliarr&lt;br /&gt;
* helicon&lt;br /&gt;
* helixcartmod&lt;br /&gt;
* helix&lt;br /&gt;
* hetch&lt;br /&gt;
* hwt_trace_rays&lt;br /&gt;
* hwt_travel_cube&lt;br /&gt;
* igrad1&lt;br /&gt;
* igrad2&lt;br /&gt;
* init_3d&lt;br /&gt;
* initpar&lt;br /&gt;
* init_sep3d&lt;br /&gt;
* init_sep3d_par&lt;br /&gt;
* init_sep3d_tag&lt;br /&gt;
* integer&lt;br /&gt;
* interpolate_mod&lt;br /&gt;
* invint2&lt;br /&gt;
* irls&lt;br /&gt;
* lapfac&lt;br /&gt;
* lint1&lt;br /&gt;
* lint2&lt;br /&gt;
* lopef&lt;br /&gt;
* lsqr&lt;br /&gt;
* make_unpipe&lt;br /&gt;
* matmult&lt;br /&gt;
* misinput&lt;br /&gt;
* mshconest&lt;br /&gt;
* mshelicon&lt;br /&gt;
* nbound&lt;br /&gt;
* nhconest&lt;br /&gt;
* nhelicon&lt;br /&gt;
* nhelix&lt;br /&gt;
* nmis2&lt;br /&gt;
* nmo_mod&lt;br /&gt;
* nonlin_solver&lt;br /&gt;
* npef&lt;br /&gt;
* npolydiv&lt;br /&gt;
* pad_it&lt;br /&gt;
* partan&lt;br /&gt;
* patch&lt;br /&gt;
* pefest&lt;br /&gt;
* pef&lt;br /&gt;
* polydiv&lt;br /&gt;
* pqueue&lt;br /&gt;
* print_sep3d&lt;br /&gt;
* putch&lt;br /&gt;
* puthead&lt;br /&gt;
* quantile&lt;br /&gt;
* quick_sort&lt;br /&gt;
* refft&lt;br /&gt;
* refine2&lt;br /&gt;
* regrid&lt;br /&gt;
* rms2int&lt;br /&gt;
* rvfft&lt;br /&gt;
* sep3d_add_drn&lt;br /&gt;
* sep3d_axes_allocate&lt;br /&gt;
* sep3d_axis_index&lt;br /&gt;
* sep3dc_clean&lt;br /&gt;
* sep3dc_collect_data&lt;br /&gt;
* sep3dc_collect_headers&lt;br /&gt;
* sep3dc_conform&lt;br /&gt;
* sep3dc_coord_copy&lt;br /&gt;
* sep3dc_copy&lt;br /&gt;
* sep3dc_delete&lt;br /&gt;
* sep3dc_desection_tag&lt;br /&gt;
* sep3dc_distribute_data&lt;br /&gt;
* sep3dc_distribute_headers&lt;br /&gt;
* sep3dc_ge_space&lt;br /&gt;
* sep3dc_grab_grid_values&lt;br /&gt;
* sep3dc_grab_headers&lt;br /&gt;
* sep3dc_grab_key_vali&lt;br /&gt;
* sep3dc_grab_key_vals&lt;br /&gt;
* sep3dc_grid_copy&lt;br /&gt;
* sep3dc_header_copy&lt;br /&gt;
* sep3dc_inorder&lt;br /&gt;
* sep3dc_key_index&lt;br /&gt;
* sep3dc_local_buffer_size&lt;br /&gt;
* sep_3d_close&lt;br /&gt;
* sep3dc_ndims&lt;br /&gt;
* sep3d_collect_data&lt;br /&gt;
* sep3d_collect_headers&lt;br /&gt;
* sep3d_conform&lt;br /&gt;
* sep3d_copy&lt;br /&gt;
* sep3dc_read_data&lt;br /&gt;
* sep3dc_reshape&lt;br /&gt;
* sep3dc_rite_num_traces&lt;br /&gt;
* sep3dc_section_tag&lt;br /&gt;
* sep3dc_set_grid_values&lt;br /&gt;
* sep3dc_set_key_vals&lt;br /&gt;
* sep3dc_set_number_headers&lt;br /&gt;
* sep3dc_update_ntraces&lt;br /&gt;
* sep3dc_write_description&lt;br /&gt;
* sep3dc_write_status&lt;br /&gt;
* sep3d_desection&lt;br /&gt;
* sep3d_distribute_data&lt;br /&gt;
* sep3d_distribute_headers&lt;br /&gt;
* sep3df&lt;br /&gt;
* sep3d_ge_space&lt;br /&gt;
* sep3d_grab_coords&lt;br /&gt;
* sep3d_grab_grid_values&lt;br /&gt;
* sep3d_grab_headers&lt;br /&gt;
* sep3d_grab_key_vals&lt;br /&gt;
* sep3d_grab_sect_param&lt;br /&gt;
* sep3d_grab_sep3d&lt;br /&gt;
* sep3d_grid_copy&lt;br /&gt;
* sep3d_header_copy&lt;br /&gt;
* sep3d_initialize&lt;br /&gt;
* sep3d_key_allocate&lt;br /&gt;
* sep3d_key_index&lt;br /&gt;
* sep3d_local_buffer_size&lt;br /&gt;
* sep3d_ndims&lt;br /&gt;
* sep3d_own&lt;br /&gt;
* sep3d_read_data&lt;br /&gt;
* sep3d_reshape&lt;br /&gt;
* sep3d_rite_num_traces&lt;br /&gt;
* sep3d_section&lt;br /&gt;
* sep3d_section_tag&lt;br /&gt;
* sep3d_set_coords&lt;br /&gt;
* sep3d_set_key_vals&lt;br /&gt;
* sep3d_set_number_headers&lt;br /&gt;
* sep3d_set_sect_param&lt;br /&gt;
* sep3d_set_sep3d&lt;br /&gt;
* sep3d_store_grid_values&lt;br /&gt;
* sep3d_synch&lt;br /&gt;
* sep3d_update_ntraces&lt;br /&gt;
* sep3d_with_drn&lt;br /&gt;
* sep3d_write_data&lt;br /&gt;
* sep3d_write_description&lt;br /&gt;
* separg&lt;br /&gt;
* sep_copy_gff&lt;br /&gt;
* sep_copy_grid&lt;br /&gt;
* sep_copy_header_keys&lt;br /&gt;
* sep_copy_hff&lt;br /&gt;
* seperr&lt;br /&gt;
* sep_extract_val_by_index&lt;br /&gt;
* sep_get_data_axis_par&lt;br /&gt;
* sep_get_grid_axis_par&lt;br /&gt;
* sep_get_grid_window&lt;br /&gt;
* sep_get_header_axis_par&lt;br /&gt;
* sep_get_key_fmt&lt;br /&gt;
* sep_get_key_index&lt;br /&gt;
* sep_get_key_name&lt;br /&gt;
* sep_get_key_type&lt;br /&gt;
* sep_get_number_data_axes&lt;br /&gt;
* sep_get_number_grid_axes&lt;br /&gt;
* sep_get_number_header_axes&lt;br /&gt;
* sep_get_number_keys&lt;br /&gt;
* sep_get_val_by_index&lt;br /&gt;
* sep_get_val_by_name&lt;br /&gt;
* sep_get_val_headers&lt;br /&gt;
* sep_put_data_axis_par&lt;br /&gt;
* sep_put_grid_axis_par&lt;br /&gt;
* sep_put_grid_window&lt;br /&gt;
* sep_put_header_axis_par&lt;br /&gt;
* sep_put_key&lt;br /&gt;
* sep_put_number_keys&lt;br /&gt;
* sep_put_val_by_index&lt;br /&gt;
* sep_put_val_headers&lt;br /&gt;
* sep_reorder_data_fast&lt;br /&gt;
* sep_reorder_data&lt;br /&gt;
* sep_set_no_grid&lt;br /&gt;
* sep_set_no_headers&lt;br /&gt;
* sepwarn&lt;br /&gt;
* sgainpar&lt;br /&gt;
* signoi&lt;br /&gt;
* slice&lt;br /&gt;
* solver&lt;br /&gt;
* solver_prec&lt;br /&gt;
* solver_reg&lt;br /&gt;
* spp&lt;br /&gt;
* sqroot&lt;br /&gt;
* sreed&lt;br /&gt;
* sreed_window&lt;br /&gt;
* srite&lt;br /&gt;
* srite_window&lt;br /&gt;
* sseek_block&lt;br /&gt;
* sseek&lt;br /&gt;
* ssize_block&lt;br /&gt;
* ssize&lt;br /&gt;
* steepdip&lt;br /&gt;
* steering&lt;br /&gt;
* tgettr&lt;br /&gt;
* tputtr&lt;br /&gt;
* triangle1&lt;br /&gt;
* triangle2&lt;br /&gt;
* triangle&lt;br /&gt;
* valid_structure&lt;br /&gt;
* velan_subs_mod&lt;br /&gt;
* velsimp&lt;br /&gt;
* veltran&lt;br /&gt;
* weicam_init&lt;br /&gt;
* weight&lt;br /&gt;
* weihcig_init&lt;br /&gt;
* weihcig&lt;br /&gt;
* weipcig_init&lt;br /&gt;
* weipcig&lt;br /&gt;
* weisll_init&lt;br /&gt;
* weisll&lt;br /&gt;
* weissf_init&lt;br /&gt;
* weissf&lt;br /&gt;
* weiwem_init&lt;br /&gt;
* weiwem&lt;br /&gt;
* wilson&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Code_Projects&amp;diff=2409</id>
		<title>Code Projects</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Code_Projects&amp;diff=2409"/>
		<updated>2012-10-07T20:43:38Z</updated>

		<summary type="html">&lt;p&gt;Nick: svgpen&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you are a software developer, you can help Madagascar with one of the following projects:&lt;br /&gt;
&lt;br /&gt;
===Binary packages===&lt;br /&gt;
&lt;br /&gt;
For ease of installation, we would like to distribute Madagascar not only in the source form but also in binary packages. This is [https://sourceforge.net/p/rsf/feature-requests/5/ Feature Request #5]. &lt;br /&gt;
&lt;br /&gt;
* RPM&lt;br /&gt;
&lt;br /&gt;
See [[Packaging_madagascar|Instructions for creating Fedora RPM]]. &lt;br /&gt;
&lt;br /&gt;
* Debian&lt;br /&gt;
* Macports&lt;br /&gt;
* Cygwin&lt;br /&gt;
&lt;br /&gt;
===XTpen replacement===&lt;br /&gt;
&lt;br /&gt;
The default viewing program for Linux, &#039;&#039;&#039;xtpen&#039;&#039;&#039;, depends on the Athena sidget set ([http://en.wikipedia.org/wiki/Xaw libXaw library]). The &amp;lt;tt&amp;gt;libXaw&amp;lt;/tt&amp;gt; library is no longer supplied by default with common Linux distributions. Therefore, it would be good to replace &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; with a program of similar functionality that would built with the libraries supplied out of the box.&lt;br /&gt;
&lt;br /&gt;
An alternative viewing program, &#039;&#039;&#039;oglpen&#039;&#039;&#039;, depends on [http://en.wikipedia.org/wiki/Opengl OpenGL] which is also not always available. &#039;&#039;&#039;x11pen&#039;&#039;&#039; depends only on the core X libraries but is broken.&lt;br /&gt;
&lt;br /&gt;
See also [https://sourceforge.net/p/rsf/feature-requests/34/ Feature Request #34] for &#039;&#039;&#039;aquapen&#039;&#039;&#039; on Macs.&lt;br /&gt;
&lt;br /&gt;
===Interactivity===&lt;br /&gt;
&lt;br /&gt;
At the 2011 [[Houston 2011|workshop in Houston]], Joe Dellinger presented a [http://www.beg.utexas.edu/pttc/2011/2011_pres_02_07_dellinger.pdf detailed plan] for adding interactivity to Vplot graphics. Someone needs to follow the plan and implement the suggested changes. The currently broken elementary interactivity in &#039;&#039;&#039;xtpen&#039;&#039;&#039; is [http://sourceforge.net/p/rsf/bugs/8/ Bug #8].&lt;br /&gt;
&lt;br /&gt;
===3D viewer===&lt;br /&gt;
&lt;br /&gt;
Sometimes interactive capabilies are needed not to produce reproducible results but simply to quickly browse through the data. A 3-D interactive viewer for RSF files could be a standalone program simplifying data browsing.&lt;br /&gt;
&lt;br /&gt;
[http://www.ahay.org/RSF/sfthreedcube.html sfthreedcube] is a start.&lt;br /&gt;
&lt;br /&gt;
===svgpen===&lt;br /&gt;
Add a svgpen to vplot, so vplot-based utilities can output SVG files that use png or jpg for the raster background parts. Then any web browser can be used as a viewer, and interactivity can be added via javascript.&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Download&amp;diff=2408</id>
		<title>Download</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Download&amp;diff=2408"/>
		<updated>2012-10-07T20:36:17Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Current development version */ new download procedure for developers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_2043821_XS.jpg|right|]]&lt;br /&gt;
You can choose to download either the latest stable release, or the current development version (frequently updated).&lt;br /&gt;
&lt;br /&gt;
==Stable release==&lt;br /&gt;
&lt;br /&gt;
[http://sourceforge.net/projects/rsf/files/ Download the source code distribution from Sourceforge], then unpack the directory with &lt;br /&gt;
&amp;lt;pre&amp;gt;gunzip &amp;lt; madagascar-*.tar.gz | tar xvf -&amp;lt;/pre&amp;gt;&lt;br /&gt;
or &lt;br /&gt;
&amp;lt;pre&amp;gt;bunzip2 &amp;lt; madagascar-*.tar.bz2 | tar xvf -&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;bz2&amp;lt;/tt&amp;gt; file is a bit smaller, but takes longer to unpack. &lt;br /&gt;
&lt;br /&gt;
Next, follow [[Installation|Installation instructions]] to install.&lt;br /&gt;
&lt;br /&gt;
==Current development version==&lt;br /&gt;
&lt;br /&gt;
To download the most recent Madagascar source code, you need to have a [http://subversion.apache.org/ Subversion client] (&amp;lt;tt&amp;gt;svn&amp;lt;/tt&amp;gt;) installed. If you want to download it read-only, run the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn co &amp;lt;nowiki&amp;gt;http://svn.code.sf.net/p/rsf/code/trunk&amp;lt;/nowiki&amp;gt; RSFSRC&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Replace &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; with the path where you want to put the Madagascar source code.&lt;br /&gt;
If you are a Madagascar project contributor and you want to download it in read-write mode, use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn co \&lt;br /&gt;
--username=&amp;lt;your_sourceforge_username&amp;gt; \&lt;br /&gt;
svn+ssh://&amp;lt;your_sourceforge_username&amp;gt;@svn.code.sf.net/p/rsf/code/trunk \&lt;br /&gt;
RSFSRC&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, follow [[Installation|Installation instructions]] to install.&lt;br /&gt;
&lt;br /&gt;
You can also [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/ browse the Subversion repository].&lt;br /&gt;
&lt;br /&gt;
===Updating===&lt;br /&gt;
&lt;br /&gt;
To update the Madagascar source code on your computer with the changes made by developers, &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to the directory where you placed the sources and run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn update&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
  &lt;br /&gt;
*If, after running the &amp;lt;tt&amp;gt;svn co...&amp;lt;/tt&amp;gt; command, nothing happens, no message, no return to the command line: you may be behind a proxy. This is especially likely if your computer is on a corporate Intranet.  To get past a proxy, you need to tell Subversion: (1) The IP number or URL of the proxy and (2) the port that will allow &amp;lt;tt&amp;gt;svn&amp;lt;/tt&amp;gt; through &amp;amp;ndash; most likely 80, the standard HTTP port. Open your &amp;lt;tt&amp;gt;~/.subversion/servers&amp;lt;/tt&amp;gt; file in a text editor. If this file does not exist, running any &amp;lt;tt&amp;gt;svn&amp;lt;/tt&amp;gt; command (even an unsuccessful one, like the one above) will automatically create the file. In the &amp;lt;tt&amp;gt;[global]&amp;lt;/tt&amp;gt; section, add the following lines, with your own proxy URL and port names instead of the dummy ones below: &lt;br /&gt;
&amp;lt;pre&amp;gt;http-proxy-host = www-proxy.yourcompany.com&lt;br /&gt;
http-proxy-port = 80&lt;br /&gt;
&amp;lt;/pre&amp;gt; Now your &amp;lt;tt&amp;gt;svn&amp;lt;/tt&amp;gt; commands should work. You can find more details [http://subversion.tigris.org/faq.html#proxy in the Subversion documentation]. It would also be a good idea to set in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.cshrc&amp;lt;/tt&amp;gt; the environment variable &amp;lt;tt&amp;gt;HTTP_PROXY&amp;lt;/tt&amp;gt; to your adaptation of &amp;lt;pre&amp;gt;http://www-proxy.yourcompany.com:80&amp;lt;/pre&amp;gt; so that input datasets for reproducible figures can be downloaded automatically when you need them.&lt;br /&gt;
&lt;br /&gt;
*If you get a &amp;quot;is already a working copy for a different URL&amp;quot; error, this means you have an existing directory downloaded from another server. Run &amp;lt;tt&amp;gt;svn switch --relocate&amp;lt;/tt&amp;gt; to switch servers.&lt;br /&gt;
&lt;br /&gt;
*If you are using an old Linux distribution (e.g. RedHat 9), the version of Subversion included with your distribution may need to be updated to handle the secure URL (&amp;lt;nowiki&amp;gt;https://&amp;lt;/nowiki&amp;gt;).  If &amp;lt;tt&amp;gt;svn&amp;lt;/tt&amp;gt; complains about an &amp;quot;unrecognized URL scheme&amp;quot; (and you&#039;ve given it the correctly formatted URL), then you need to update it.&lt;br /&gt;
&lt;br /&gt;
*If you are behind a firewall, you may need to set up more variables in your file &amp;lt;tt&amp;gt;~/.subversion/servers&amp;lt;/tt&amp;gt; (check with your IT support for all the required variables to get past the proxy) as for example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[global]&lt;br /&gt;
http-proxy-host = proxy-host-company.site.corp &lt;br /&gt;
http-proxy-port = 1111&lt;br /&gt;
http-proxy-username = Yourusernameforproxy&lt;br /&gt;
http-proxy-password = Yourpasswordforproxy &lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
It would be a good idea then to protect your file &amp;lt;tt&amp;gt;~/.subversion/servers&amp;lt;/tt&amp;gt; from being read by others.&lt;br /&gt;
&lt;br /&gt;
==Other packages==&lt;br /&gt;
There are two other packages that might be useful in conjunction with RSF:&lt;br /&gt;
===Reproducible figures===&lt;br /&gt;
  &lt;br /&gt;
Using Subversion, run &lt;br /&gt;
&amp;lt;pre&amp;gt;svn co http://svn.code.sf.net/p/rsf/code/figs $RSFROOT/share/madagascar/figs &amp;lt;/pre&amp;gt; &lt;br /&gt;
This installs a wide collection of more than 5,000 reproducible figures. It may take a long time to download and more than 6 Gb of disk space.&lt;br /&gt;
The figures are preserved with the purpose of regression testing whenever the software or the environment change.&lt;br /&gt;
&lt;br /&gt;
You can reproduce the figures (excluding those generated with proprietary data or additional software) by running &amp;lt;tt&amp;gt;scons lock&amp;lt;/tt&amp;gt; in individual project directories or by going to &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; and running &lt;br /&gt;
&amp;lt;pre&amp;gt;sfbooklist command=&amp;quot;scons lock&amp;quot; book&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===L&amp;lt;sup&amp;gt;A&amp;lt;/sup&amp;gt;TEX package===&lt;br /&gt;
  &lt;br /&gt;
[[SEGTeX]] is a LaTeX package for geophysical publications. It can be used with madagascar for writing [[Reproducible Documents|reproducible papers]].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=2361</id>
		<title>Adding new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Adding_new_programs_to_Madagascar&amp;diff=2361"/>
		<updated>2012-08-15T23:33:11Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Wiki documentation */ updated path&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_800161_XS.jpg|right|]]&lt;br /&gt;
Whether you want to share your work with the world or keep it for yourself, madagascar is fully extensible. The following instructions explain the simplest way to add your own programs to the package.&lt;br /&gt;
&lt;br /&gt;
==How to add your program==&lt;br /&gt;
  &lt;br /&gt;
#Create a directory for yourself or your group under &amp;lt;tt&amp;gt;RSFSRC/user&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;RSFSRC&amp;lt;/tt&amp;gt; is the top source directory. Put your programs there.&lt;br /&gt;
#The following conventions are adopted:&lt;br /&gt;
#*Files containing main programs start with &amp;lt;tt&amp;gt;M&amp;lt;/tt&amp;gt;, i.e. &amp;lt;tt&amp;gt;Mmyprog.c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Mmyprog.py&amp;lt;/tt&amp;gt;. Each main program file should start with a short one-line comment describing its purpose. &lt;br /&gt;
#*Files containing subroutines start with small letters. A header/interface file &amp;lt;tt&amp;gt;myprog.h&amp;lt;/tt&amp;gt; is automatically generated from &amp;lt;tt&amp;gt;myprog.c&amp;lt;/tt&amp;gt;. By using header files, dependencies between different functions will be figured out automatically. Include a comment of the form &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;/*^*/&amp;lt;/font&amp;gt; after any block of text that you want to be included in the header file. &#039;&#039;Such blocks must not contain any all-whitespace lines.&#039;&#039; Include a comment of the form &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;/*&amp;lt; My function description &amp;gt;*/&amp;lt;/font&amp;gt; after a function definition if you want its interface included in the header file.  It is a good habit to comment interfaces to all your functions. &lt;br /&gt;
#Create a &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in your directory by following examples from other &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; directories. Inside the triple quotation marks after &amp;lt;tt&amp;gt;progs=&amp;lt;/tt&amp;gt;, replace the names of their programs with the names of your programs with spaces between the names. &lt;br /&gt;
#Note that running &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; inside your &amp;lt;tt&amp;gt;user&amp;lt;/tt&amp;gt; directory compiles programs with debugging flags to make them suitable for debugging with common debuggers such as [http://www.gnu.org/software/gdb/ gdb], dbx, or [http://www.etnus.com/ TotalView]. Running  &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; inside the top source directory will compile your programs with optimization flags and install them in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==How to share your program with others==&lt;br /&gt;
&lt;br /&gt;
Follow the guide on [[Contributing new programs to Madagascar]].&lt;br /&gt;
&lt;br /&gt;
==How to document your program==&lt;br /&gt;
There are three levels of documentation. From the most simple to the most complex, they are: in-code documentation, the Wiki, and reproducible papers. &lt;br /&gt;
===In-code documentation===&lt;br /&gt;
Of course, do comment your code -- focusing on &amp;quot;why&amp;quot; (the code itself describes the &amp;quot;how&amp;quot;). Keep comments sparse so that as much code as possible can be kept in mind at the same time by the human reader. Use the other levels for more information.&lt;br /&gt;
 &lt;br /&gt;
If you follow a certain syntax for some of your comments, then the scripts in the Madagascar framework will be able to automatically produce a self-doc page for your program. This page will be displayed in the terminal (using basic text-mode formatting) when the program is invoked without any arguments, and a HTML version will be automatically generated in $RSFDOC (default: $RSFROOT/doc). The self-doc page has the following sections: &amp;lt;tt&amp;gt;Name&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Used in&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Source&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Version&amp;lt;/tt&amp;gt;. &lt;br /&gt;
====Self-doc for C programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; sections, use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Short description line&lt;br /&gt;
Comments here blablabla lorem ipsum dolores sit amet...&lt;br /&gt;
&lt;br /&gt;
You can use several paragraphs for comments, no problem.*/&lt;br /&gt;
&lt;br /&gt;
/* Copyright notice */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
Notice that: (1) the description line is the first line in the file; (2) Comments are closed and then open again on a new line for Copyright (so that Copyright does not show up in the documentation).&lt;br /&gt;
&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to read the parameters in the code like in the following example:&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
if (!sf_getbool(&amp;quot;su&amp;quot;,&amp;amp;su)) su=false;&lt;br /&gt;
/* y if input is SU, n if input is SEGY */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
Notice that there are no complex logical operations inside the &amp;lt;tt&amp;gt;if&amp;lt;/tt&amp;gt;, that there is no space between the equal sign and the right and left hand, and that a short comment follows immediately. If by necessity the parameter is read in a complex fashion, use angular brackets inside the short line following the read block, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
... sf_getfloat ... complex stuff ...&lt;br /&gt;
/*&amp;lt; parameter_name parameter meaning &amp;gt;*/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Self-doc for Python programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; page, and &amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; sections, use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#! /usr/bin/env python&lt;br /&gt;
&#039;&#039;&#039;My one-line description of this program&lt;br /&gt;
If I have comments, put them in the lines below.&lt;br /&gt;
&lt;br /&gt;
I can use several paragraphs for that&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# Copyright notice...&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Then, make sure to&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import rsfprog&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to follow each argument read with a comment, and call &amp;lt;tt&amp;gt;selfdoc&amp;lt;/tt&amp;gt; if no argument was given. Here is an example from &amp;lt;tt&amp;gt;user/ivlad/Mpclip.py&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
    par = rsf.Par(argv)&lt;br /&gt;
&lt;br /&gt;
    inp = par.string(&#039;inp&#039;) # input file&lt;br /&gt;
    out = par.string(&#039;out&#039;) # output file&lt;br /&gt;
    if None in (inp, out):&lt;br /&gt;
        rsfprog.selfdoc()   # self-doc&lt;br /&gt;
        return error&lt;br /&gt;
&lt;br /&gt;
    verb = par.bool(&#039;verb&#039;, False) # if y, print system commands, outputs&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Self-doc for Fortran 90 programs====&lt;br /&gt;
To automatically populate the &amp;lt;tt&amp;gt;Description&amp;lt;/tt&amp;gt; section (&amp;lt;tt&amp;gt;Comments&amp;lt;/tt&amp;gt; is not available), use the following syntax. Start the file with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! One-line short description, leave a blank line after it&lt;br /&gt;
&lt;br /&gt;
! Copyright notice...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make input parameters and their default values (if they exist) automatically appear in the &amp;lt;tt&amp;gt;Synopsis&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Parameters&amp;lt;/tt&amp;gt; sections, make sure to read the parameters in the code like in the following example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
call from_par( &amp;quot;n1&amp;quot;, nt, 512 ) ! Param description on same line or first line after&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Wiki documentation===&lt;br /&gt;
The self-doc is good as a reminder of what the parameters mean and what their default values are, but more is usually needed for someone who never used the tool. This is what the [[Guide to madagascar programs|Guide to programs]] is for. Whenever you change or create a program, make sure to add a section for it in there too, if possible with an implementation section. Documenting programs that already exist is also a great idea.&lt;br /&gt;
&lt;br /&gt;
You may have noticed that each program section on that page starts with a table that has the same content as the self-doc. That is created automatically the following way. Say you want to create this table for &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;. At a command line, type:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfdoc -m $HOME attr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will create the file &amp;lt;tt&amp;gt;$HOME/sfattr.wiki&amp;lt;/tt&amp;gt;. Its content can be copied and pasted into the Madagascar wiki, as they already are in the MediaWiki format. Another directory can be used instead of $HOME.&lt;br /&gt;
&lt;br /&gt;
If your program/script reads an environment variable, make sure you check [[Advanced Installation#Environment variables|the list of environment variables used by Madagascar]] and add your new variable or your peculiar usage of an existing variable.&lt;br /&gt;
&lt;br /&gt;
After creating the appropriate section in the [[Guide to madagascar programs|Guide to programs]], add your program name without the &amp;lt;tt&amp;gt;sf&amp;lt;/tt&amp;gt; prefix to the &amp;lt;tt&amp;gt;docprogs&amp;lt;/tt&amp;gt; list at the beginning of &amp;lt;tt&amp;gt;RSFSRC/framework/rsf/doc.py&amp;lt;/tt&amp;gt; . This will ensure that a link to the wiki section is created in the auto-generated HTML program page in &amp;lt;tt&amp;gt;$RSFDOC&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Add your program to the [[Task-centric program list]] so that it can be found by those users who do not already know they need it.&lt;br /&gt;
&lt;br /&gt;
===Reproducible documents===&lt;br /&gt;
&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; programs are tested and illustrated by means of [[Reproducible_Documents|reproducible documents]]. See the [[Reproducible computational experiments using SCons|Guide to SCons interface for reproducible computations]] for a brief explanation of what a reproducible paper is and how to produce one.&lt;br /&gt;
&lt;br /&gt;
==Style guide==&lt;br /&gt;
* Use components (macros, types, functions) from the Madagascar library to maximize component reuse and to make sure you do not reinvent the wheel. Be familiar with the [[Library Reference]].&lt;br /&gt;
* User interface convention: if your program provides a verbosity option, use &amp;lt;tt&amp;gt;verb=n [y/n]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Do not keep commented code in your program. This does not refer to writing comments about code, but to commenting out actual code. You can always use the version control system to retrieve the older version&lt;br /&gt;
* Initialize all pointers (including variables of type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;) with NULL&lt;br /&gt;
* If you have one or more calls to &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; in your program, call &amp;lt;tt&amp;gt;sf_close&amp;lt;/tt&amp;gt; before exit to avoid file leaks (temporary files left in $DATAPATH after an operation involving pipes)&lt;br /&gt;
&lt;br /&gt;
==How to test your program==&lt;br /&gt;
The testing mechanism is semi-automatic. Testing can be done for any program that is used in a reproducible document in the &amp;lt;tt&amp;gt;RSF/book&amp;lt;/tt&amp;gt; directory. To test whether the change you made in a program called, say, &amp;lt;tt&amp;gt;sfmyprog&amp;lt;/tt&amp;gt; introduced any new bugs, make sure you have the latest set of stored figures from the [[Installation#RSF_reproducible_figures|figures repository]] and do the following:&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;tt&amp;gt;cd RSF/book&amp;lt;/tt&amp;gt;&lt;br /&gt;
#Run &amp;lt;pre&amp;gt;scons sfmyprog.test&amp;lt;/pre&amp;gt; If the error messages are not helpful you can omit them from the console, but keep them in a file like this (sh): &amp;lt;pre&amp;gt;scons sfmyprog.test 2&amp;gt; sfmyprog.test.err&amp;lt;/pre&amp;gt; or like this (csh): &amp;lt;pre&amp;gt;(scons sfmyprog.test &amp;gt; /dev/stdin) &amp;gt;&amp;amp; sfmyprog.test.err&amp;lt;/pre&amp;gt;&lt;br /&gt;
#If testing fails, find the directory and figure where failure happened from the &amp;quot;&amp;lt;tt&amp;gt;Comparing ... and ...&amp;lt;/tt&amp;gt;&amp;quot; statement just before the beginning of the error messages. The directory name will appear before that in a line &amp;quot;&amp;lt;tt&amp;gt; Testing in ...&amp;lt;/tt&amp;gt;&amp;quot;. &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to that directory. Let&#039;s say the figure that failed is called &amp;lt;tt&amp;gt;myfig.vpl&amp;lt;/tt&amp;gt;. Run &amp;lt;pre&amp;gt;scons myfig.flip&amp;lt;/pre&amp;gt; That will open a graphical display window that will quickly alternate between the stored figure and your figure. &lt;br /&gt;
#* If the figures look identical, then it means the differences are due to rounding errors and other insignificant differences between platforms (work is done on improving the comparison mechanism). Load your figure into your copy of the figures repository with &amp;lt;pre&amp;gt;scons myfig.lock&amp;lt;/pre&amp;gt;&lt;br /&gt;
#* If you see differences between the two figures, then it is time to debug your program.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
===Backups===&lt;br /&gt;
You may want to back up only your developer directory, not the entire Madagascar source tree. If you do not want to or do not have the permissions to change the backup scripts, you will need to make your RSF user directory a link to somewhere else. To get that to work, you need to modify your &amp;lt;tt&amp;gt;username/SConstruct&amp;lt;/tt&amp;gt;. First thing in the file, define &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
RSF_src_root = &#039;/path/to/madagascar/source/root/&#039;&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Then, replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
os.path.join(RSF_src_root,&#039;whatever_followed_after_dotdots&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
===External libraries===&lt;br /&gt;
To link your programs to an external library, add to the &amp;lt;tt&amp;gt;env.Prepend&amp;lt;/tt&amp;gt; statement in &amp;lt;tt&amp;gt;username/Sconstruct&amp;lt;/tt&amp;gt;&lt;br /&gt;
the paths to its &amp;lt;tt&amp;gt;include&amp;lt;/tt&amp;gt; dir, &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt; dir and the name of the library you are linking to.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Emacs customization===&lt;br /&gt;
&lt;br /&gt;
If you use [http://www.gnu.org/software/emacs/ Emacs], the following might be helpful.&lt;br /&gt;
&lt;br /&gt;
* Install the [http://www.emacswiki.org/cgi-bin/wiki/PythonMode python mode] (if you don&#039;t have it installed already) and put &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(setq auto-mode-alist&lt;br /&gt;
      (cons &#039;(&amp;quot;SConstruct&amp;quot; . python-mode) auto-mode-alist))&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:in your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file to enable it on &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files.&lt;br /&gt;
&lt;br /&gt;
* Put &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(set-default &#039;compile-command &amp;quot;scons&amp;quot;)&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:in your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file to have &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; as the default compile command.&lt;br /&gt;
&lt;br /&gt;
* Use &lt;br /&gt;
&amp;lt;lisp&amp;gt;&lt;br /&gt;
(add-hook &#039;c-mode-common-hook&lt;br /&gt;
   &#039;(lambda () (c-set-style &amp;quot;linux&amp;quot;)&lt;br /&gt;
        (c-set-offset &#039;case-label 4)&lt;br /&gt;
        (setq c-basic-offset 4)))&lt;br /&gt;
&amp;lt;/lisp&amp;gt; &lt;br /&gt;
:to make sure that the identation in C files follows the previously adopted convention.&lt;br /&gt;
&lt;br /&gt;
=== Vim customization ===&lt;br /&gt;
&lt;br /&gt;
To enable syntax highlighting on SConstruct files in vim, add the following to your &amp;lt;tt&amp;gt;~/.vimrc&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
au BufRead,BufNewFile SConstruct setfiletype python&lt;br /&gt;
&lt;br /&gt;
syntax enable&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=2360</id>
		<title>Guide to madagascar programs</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=2360"/>
		<updated>2012-08-15T23:22:03Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* sfawefd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/prog.tex?view=markup book/rsf/rsf/prog.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide introduces some of the most used &amp;lt;tt&amp;gt;madagascar&amp;lt;/tt&amp;gt; programs and illustrates their usage with examples.&lt;br /&gt;
=Main programs=&lt;br /&gt;
The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/ system/main] in the Madagascar distribution. The &amp;quot;main&amp;quot; programs perform general-purpose operations on RSF hypercubes regardless of the data dimensionality or physical dimensions.&lt;br /&gt;
&lt;br /&gt;
==sfadd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add, multiply, or divide  RSF datasets.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfadd &amp;gt; out.rsf scale= add= sqrt= abs= log= exp= mode= [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | The various operations, if selected, occur in the following order:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;(1) Take absolute value, abs=&amp;lt;br&amp;gt;(2) Add a scalar, add=&amp;lt;br&amp;gt;(3) Take the natural logarithm, log=&amp;lt;br&amp;gt;(4) Take the square root, sqrt=&amp;lt;br&amp;gt;(5) Multiply by a scalar, scale=&amp;lt;br&amp;gt;(6) Compute the base-e exponential, exp=&amp;lt;br&amp;gt;(7) Add, multiply, or divide the data sets, mode=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfadd operates on integer, float, or complex data, but all the input&amp;lt;br&amp;gt;and output files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfadd is sfmath, which is more versatile, but may be&amp;lt;br&amp;gt;less efficient.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;abs=&#039;&#039;&#039; ||   || 	If true take absolute value  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;add=&#039;&#039;&#039; ||   || 	Scalar values to add to each dataset  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;exp=&#039;&#039;&#039; ||   || 	If true compute exponential  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;log=&#039;&#039;&#039; ||   || 	If true take logarithm  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mode=&#039;&#039;&#039; ||   || 	&#039;a&#039; means add (default), &amp;lt;br&amp;gt;       &#039;p&#039; or &#039;m&#039; means multiply, &amp;lt;br&amp;gt;       &#039;d&#039; means divide&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;scale=&#039;&#039;&#039; ||   || 	Scalar values to multiply each dataset with  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;sqrt=&#039;&#039;&#039; ||   || 	If true take square root  [nin]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfadd&amp;lt;/tt&amp;gt; is useful for combining (adding, dividing, or&lt;br /&gt;
multiplying) several datasets. What if you want to subtract two&lt;br /&gt;
datasets? Easy. Use the &amp;lt;tt&amp;gt;scale&amp;lt;/tt&amp;gt; parameter as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd &amp;lt; data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The same task can be accomplished with the more general &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; program:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath one=data1.rsf two=data2.rsf output=&#039;one-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath &amp;lt; data1.rsf two=data2.rsf output=&#039;input-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In both cases, the size and shape of &amp;lt;tt&amp;gt;data1.rsf&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;data2.rsf&amp;lt;/tt&amp;gt; hypercubes should be the same, and a warning&lt;br /&gt;
message is printed out if the the axis sampling parameters (such as&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;) in these files are different.&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/add.c?view=markup system/main/add.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* find number of input files */&lt;br /&gt;
    if (isatty(fileno(stdin))) { &lt;br /&gt;
        /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Collect input files in the &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; array from all command-line&lt;br /&gt;
parameters that don&#039;t contain an &amp;quot;&amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;&amp;quot; sign. The total number&lt;br /&gt;
of input files in &amp;lt;tt&amp;gt;nin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) continue; &lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
    /* nin = no of input files*/&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A helper function &amp;lt;tt&amp;gt;check_compat&amp;lt;/tt&amp;gt; checks the compatibility of&lt;br /&gt;
input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void &lt;br /&gt;
check_compat (sf_datatype type /* data type */, &lt;br /&gt;
	      size_t      nin  /* number of files */, &lt;br /&gt;
	      sf_file*    in   /* input files [nin] */, &lt;br /&gt;
	      int         dim  /* file dimensionality */, &lt;br /&gt;
	      const int*  n    /* dimensions [dim] */)&lt;br /&gt;
/* Check that the input files are compatible. &lt;br /&gt;
   Issue error for type mismatch or size mismatch.&lt;br /&gt;
   Issue warning for grid parameters mismatch. */&lt;br /&gt;
{&lt;br /&gt;
    int ni, id;&lt;br /&gt;
    size_t i;&lt;br /&gt;
    float d, di, o, oi;&lt;br /&gt;
    char key[3];&lt;br /&gt;
    const float tol=1.e-5; /* tolerance for comparison */&lt;br /&gt;
    &lt;br /&gt;
    for (i=1; i &amp;lt; nin; i++) {&lt;br /&gt;
	if (sf_gettype(in[i]) != type) &lt;br /&gt;
	    sf_error (&amp;quot;type mismatch: need %d&amp;quot;,type);&lt;br /&gt;
	for (id=1; id &amp;lt;= dim; id++) {&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,id);&lt;br /&gt;
	    if (!sf_histint(in[i],key,&amp;amp;ni) || ni != n[id-1])&lt;br /&gt;
		sf_error(&amp;quot;%s mismatch: need %d&amp;quot;,key,n[id-1]);&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;d%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;d)) {&lt;br /&gt;
		if (!sf_histfloat(in[i],key,&amp;amp;di) || &lt;br /&gt;
		    (fabsf(di-d) &amp;gt; tol*fabsf(d)))&lt;br /&gt;
		    sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,d);&lt;br /&gt;
	    } else {&lt;br /&gt;
		d = 1.;&lt;br /&gt;
	    }&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;o%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;o) &amp;amp;&amp;amp; &lt;br /&gt;
		(!sf_histfloat(in[i],key,&amp;amp;oi) || &lt;br /&gt;
		 (fabsf(oi-o) &amp;gt; tol*fabsf(d))))&lt;br /&gt;
		sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,o);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we enter the main loop, where input data are getting read&lt;br /&gt;
buffer by buffer and combined in the total product depending on the&lt;br /&gt;
data type.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nbuf /= sf_esize(in[0]); nsiz &amp;gt; 0; nsiz -= nbuf) {&lt;br /&gt;
	if (nbuf &amp;gt; nsiz) nbuf=nsiz;&lt;br /&gt;
&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    collect = (bool) (j != 0);&lt;br /&gt;
	    switch(type) {&lt;br /&gt;
		case SF_FLOAT:&lt;br /&gt;
		    sf_floatread((float*) bufi,&lt;br /&gt;
				 nbuf,&lt;br /&gt;
				 in[j]);	    &lt;br /&gt;
		    add_float(collect, &lt;br /&gt;
			      nbuf,&lt;br /&gt;
			      (float*) buf,&lt;br /&gt;
			      (const float*) bufi, &lt;br /&gt;
			      cmode, &lt;br /&gt;
			      scale[j], &lt;br /&gt;
			      add[j], &lt;br /&gt;
			      abs_flag[j], &lt;br /&gt;
			      log_flag[j], &lt;br /&gt;
			      sqrt_flag[j], &lt;br /&gt;
			      exp_flag[j]);&lt;br /&gt;
		    break;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data combination program for floating point numbers is&lt;br /&gt;
&amp;lt;tt&amp;gt;add_float&amp;lt;/tt&amp;gt;.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void add_float (bool   collect,    /* if collect */&lt;br /&gt;
		       size_t nbuf,       /* buffer size */&lt;br /&gt;
		       float* buf,        /* output [nbuf] */&lt;br /&gt;
		       const float* bufi, /* input  [nbuf] */  &lt;br /&gt;
		       char   cmode,      /* operation */&lt;br /&gt;
		       float  scale,      /* scale factor */&lt;br /&gt;
		       float  add,        /* add factor */&lt;br /&gt;
		       bool   abs_flag,   /* if abs */&lt;br /&gt;
		       bool   log_flag,   /* if log */&lt;br /&gt;
		       bool   sqrt_flag,  /* if sqrt */&lt;br /&gt;
		       bool   exp_flag    /* if exp */)&lt;br /&gt;
/* Add floating point numbers */&lt;br /&gt;
{&lt;br /&gt;
    size_t j;&lt;br /&gt;
    float f;&lt;br /&gt;
&lt;br /&gt;
    for (j=0; j &amp;lt; nbuf; j++) {&lt;br /&gt;
	f = bufi[j];&lt;br /&gt;
	if (abs_flag)    f = fabsf(f);&lt;br /&gt;
	f += add;&lt;br /&gt;
	if (log_flag)    f = logf(f);&lt;br /&gt;
	if (sqrt_flag)   f = sqrtf(f);&lt;br /&gt;
	if (1. != scale) f *= scale;&lt;br /&gt;
	if (exp_flag)    f = expf(f);&lt;br /&gt;
	if (collect) {&lt;br /&gt;
	    switch (cmode) {&lt;br /&gt;
		case &#039;p&#039;: /* product */&lt;br /&gt;
		case &#039;m&#039;: /* multiply */&lt;br /&gt;
		    buf[j] *= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		case &#039;d&#039;: /* delete */&lt;br /&gt;
		    if (f != 0.) buf[j] /= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		default:  /* add */&lt;br /&gt;
		    buf[j] += f;&lt;br /&gt;
		    break;&lt;br /&gt;
	    }&lt;br /&gt;
	} else {&lt;br /&gt;
	    buf[j] = f;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display dataset attributes.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfattr &amp;lt; in.rsf want=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    &amp;lt;br&amp;gt;Sample output from &amp;quot;sfspike n1=100 | sfbandpass fhi=60 | sfattr&amp;quot;&amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;rms = 0.992354 &amp;lt;br&amp;gt;mean value = 0.987576 &amp;lt;br&amp;gt;2-norm value = 9.92354 &amp;lt;br&amp;gt;variance = 0.00955481 &amp;lt;br&amp;gt;standard deviation = 0.0977487 &amp;lt;br&amp;gt;maximum value = 1.12735 at 97 &amp;lt;br&amp;gt;minimum value = 0.151392 at 100 &amp;lt;br&amp;gt;number of nonzero samples = 100 &amp;lt;br&amp;gt;total number of samples = 100 &amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;rms                = sqrt[ sum(data^2) / n ]&amp;lt;br&amp;gt;mean               = sum(data) / n&amp;lt;br&amp;gt;norm               = sum(abs(data)^lval)^(1/lval)&amp;lt;br&amp;gt;variance           = [ sum(data^2) - n*mean^2 ] / [ n-1 ]&amp;lt;br&amp;gt;standard deviation = sqrt [ variance ]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int &#039;&#039; || &#039;&#039;&#039;lval=2&#039;&#039;&#039; ||   || 	norm option, lval is a non-negative integer, computes the vector lval-norm&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;want=&#039;&#039;&#039; ||   || 	&#039;all&#039;(default),&#039;rms&#039;,&#039;mean&#039;,&#039;norm&#039;,&#039;var&#039;,&#039;std&#039;,&#039;max&#039;,&#039;min&#039;,&#039;nonzero&#039;,&#039;samples&#039;,&#039;short&#039; &lt;br /&gt;
:want=   &#039;rms&#039; displays the root mean square&lt;br /&gt;
:want=   &#039;norm&#039; displays the square norm, otherwise specified by lval.&lt;br /&gt;
:want=   &#039;var&#039; displays the variance&lt;br /&gt;
:want=   &#039;std&#039; displays the standard deviation&lt;br /&gt;
:want=   &#039;nonzero&#039; displays number of nonzero samples&lt;br /&gt;
:want=   &#039;samples&#039; displays total number of samples&lt;br /&gt;
:want=   &#039;short&#039; displays a short one-line version&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt; is a useful diagnostic program. It reports certain&lt;br /&gt;
statistical values for an RSF dataset: RMS (root-mean-square)&lt;br /&gt;
amplitude, mean value, vector norm value, variance, standard deviation,&lt;br /&gt;
maximum and minimum values, number of nonzero samples, and the total&lt;br /&gt;
number of samples.&lt;br /&gt;
If we denote data values as &amp;lt;math&amp;gt;d_i&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;i=0,1,2,\ldots,n&amp;lt;/math&amp;gt;, then the RMS&lt;br /&gt;
value is &amp;lt;math&amp;gt;\sqrt{\frac{1}{n}\,\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the mean&lt;br /&gt;
value is &amp;lt;math&amp;gt;\frac{1}{n}\,\sum\limits_{i=0}^n d_i&amp;lt;/math&amp;gt;, the &amp;lt;math&amp;gt;L_2&amp;lt;/math&amp;gt;-norm value&lt;br /&gt;
is &amp;lt;math&amp;gt;\sqrt{\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the variance is&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{n-1}\,\left[\sum\limits_{i=0}^n d_i^2 - \frac{1}{n}\left(\sum\limits_{i=0}^n d_i\right)^2\right]&amp;lt;/math&amp;gt;, and the standard&lt;br /&gt;
deviation is the square root of the variance. Using &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;&lt;br /&gt;
is a quick way to see the distribution of data values and check it for anomalies.&lt;br /&gt;
&lt;br /&gt;
The output can be parsed using utilities such as &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt;, to extract only a numeric value for feeding it as a parameter value into a command line interface. Notice the backticks in the example below:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfgrey &amp;lt;vel.rsf allpos=y bias=`sfattr &amp;lt;vel.rsf want=min | awk &#039;{print $4}&#039;` | sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/attr.c?view=markup system/main/attr.c]====&lt;br /&gt;
&lt;br /&gt;
Computations start by finding the input data (&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;) size&lt;br /&gt;
(&amp;lt;tt&amp;gt;nsiz&amp;lt;/tt&amp;gt;) and dimensions (&amp;lt;tt&amp;gt;dim&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    dim = (size_t) sf_filedims (in,n);&lt;br /&gt;
    for (nsiz=1, i=0; i &amp;lt; dim; i++) {&lt;br /&gt;
	nsiz *= n[i];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the main loop, we read the input data buffer by buffer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft=nsiz; nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (bufsiz &amp;lt; nleft)? bufsiz: nleft;&lt;br /&gt;
	switch (type) {&lt;br /&gt;
	    case SF_FLOAT: &lt;br /&gt;
		sf_floatread((float*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_INT:&lt;br /&gt;
		sf_intread((int*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_COMPLEX:&lt;br /&gt;
		sf_complexread((sf_complex*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_UCHAR:&lt;br /&gt;
		sf_ucharread((unsigned char*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_CHAR:&lt;br /&gt;
	    default:&lt;br /&gt;
		sf_charread(buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data attributes are accumulated in corresponding double-precision&lt;br /&gt;
variables. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	    fsum += f;&lt;br /&gt;
	    fsqr += f*f;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, the attributes are reduced and printed out.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    fmean = fsum/nsiz;&lt;br /&gt;
    if (lval==2)      fnorm = sqrt(fsqr);&lt;br /&gt;
    else if (lval==0) fnorm = nsiz-nzero;&lt;br /&gt;
    else              fnorm = pow(flval,1./lval);&lt;br /&gt;
    frms = sqrt(fsqr/nsiz);&lt;br /&gt;
    if (nsiz &amp;gt; 1) fvar = (fsqr-nsiz*fmean*fmean)/(nsiz-1);&lt;br /&gt;
    else          fvar = 0.0;&lt;br /&gt;
    fstd = sqrt(fvar);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;rms&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;rms = %g \n&amp;quot;,(float) frms);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;mean&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;mean value = %g \n&amp;quot;,(float) fmean);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;norm&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;%d-norm value = %g \n&amp;quot;,lval,(float) fnorm);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;var&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;variance = %g \n&amp;quot;,(float) fvar);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;std&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;standard deviation = %g \n&amp;quot;,(float) fstd);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Concatenate datasets. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcat &amp;gt; out.rsf space= axis=3 nspace=(int) (ni/(20*nin) + 1) [&amp;lt;file0.rsf] file1.rsf file2.rsf ... &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfmerge inserts additional space between merged data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis being merged&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nspace=(int) (ni/(20*nin) + 1)&#039;&#039;&#039; ||   || 	if space=y, number of traces to insert&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;space=&#039;&#039;&#039; ||  [y/n] || 	Insert additional space.&lt;br /&gt;
:y is default for sfmerge, n is default for sfcat&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; concatenate two or more files&lt;br /&gt;
together along a particular axis. It is the same program, only&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; has the default &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;&lt;br /&gt;
has the default &amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcat one.rsf one.rsf axis=1 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=4           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        12 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmerge one.rsf one.rsf axis=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=7           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        14 elements 56 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, an extra empty trace is inserted between the two merged files.&lt;br /&gt;
The axes that are not being merged are checked for consistency:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfcat one.rsf two.rsf &amp;gt; three.rsf&lt;br /&gt;
sfcat: n2 mismatch: need 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cat.c?view=markup system/main/cat.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    in = (sf_file*) sf_alloc ((size_t) argc,sizeof(sf_file));&lt;br /&gt;
&lt;br /&gt;
    if (!sf_stdin()) { /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Everything on the command line that does not contain a &amp;quot;=&amp;quot; sign is&lt;br /&gt;
treated as a file name, and the corresponding file object is added to the list.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) &lt;br /&gt;
	    continue; /* not a file */&lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As explained above, if the &amp;lt;tt&amp;gt;space=&amp;lt;/tt&amp;gt; parameter is not set, it is&lt;br /&gt;
inferred from the program name: &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; corresponds to&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; corresponds to &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if (!sf_getbool(&amp;quot;space&amp;quot;,&amp;amp;space)) {&lt;br /&gt;
	/* Insert additional space.&lt;br /&gt;
	   y is default for sfmerge, n is default for sfcat */&lt;br /&gt;
	prog = sf_getprog();&lt;br /&gt;
	if (NULL != strstr (prog, &amp;quot;merge&amp;quot;)) {&lt;br /&gt;
	    space = true;&lt;br /&gt;
	} else if (NULL != strstr (prog, &amp;quot;cat&amp;quot;)) {&lt;br /&gt;
	    space = false;&lt;br /&gt;
	} else {&lt;br /&gt;
	    sf_warning(&amp;quot;%s is neither merge nor cat,&amp;quot;&lt;br /&gt;
		       &amp;quot; assume merge&amp;quot;,prog);&lt;br /&gt;
	    space = true;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the axis for the merging (from the command line &amp;lt;tt&amp;gt;axis=&amp;lt;/tt&amp;gt;&lt;br /&gt;
argument) and figure out two sizes: &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; for everything after&lt;br /&gt;
the axis and &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; for everything before the axis.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    n1=1;&lt;br /&gt;
    n2=1;&lt;br /&gt;
    for (i=1; i &amp;lt;= dim; i++) {&lt;br /&gt;
	if      (i &amp;lt; axis) n1 *= n[i-1];&lt;br /&gt;
	else if (i &amp;gt; axis) n2 *= n[i-1];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the output, the selected axis will get extended.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* figure out the length of extended axis */&lt;br /&gt;
    ni = 0;&lt;br /&gt;
    for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	ni += naxis[j];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (space) {&lt;br /&gt;
	if (!sf_getint(&amp;quot;nspace&amp;quot;,&amp;amp;nspace)) &lt;br /&gt;
	    nspace = (int) (ni/(20*nin) + 1);&lt;br /&gt;
	/* if space=y, number of traces to insert */ &lt;br /&gt;
	ni += nspace*(nin-1);&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,axis);&lt;br /&gt;
    sf_putint(out,key,(int) ni);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest is simple: loop through the datasets reading and writing the&lt;br /&gt;
data in buffer-size chunks and adding extra empty chunks if&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    for (ni = n1*naxis[j]*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charread (buf,nbuf,in[j]);&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	    if (!space || j == nin-1) continue;&lt;br /&gt;
	    /* Add spaces */&lt;br /&gt;
	    memset(buf,0,BUFSIZ);&lt;br /&gt;
	    for (ni = n1*nspace*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;dat=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mod=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A simple demonstration of the program can be made taking advantage that the complex-to-complex FFT is a linear operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike n1=100 | sfrtoc &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt; spike.rsf sffft axis=1 pad=1 &amp;gt; spike2.rsf&lt;br /&gt;
sfcdottest sffft mod=spike.rsf dat=spike2.rsf axis=1 pad=1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should show values identical down to the last decimal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfcdottest:  L[m]*d=(3.73955,-1.86955)&lt;br /&gt;
sfcdottest: L&#039;[d]*m=(3.73955,-1.86955)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcmplx==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcmplx &amp;gt; cmplx.rsf real.rsf imag.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | There has to be only two input files specified and no additional parameters.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt; simply creates a complex dataset from its real and&lt;br /&gt;
imaginary parts. The reverse operation can be accomplished with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcmplx one.rsf one.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ sfin cmplx.rsf&lt;br /&gt;
cmplx.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/cmplx.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cmplx.c?view=markup system/main/cmplx.c]====&lt;br /&gt;
The program flow is simple. First, get the names of the input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are real and imaginary files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == real) {&lt;br /&gt;
		real = sf_input (argv[i]);&lt;br /&gt;
	    } else {&lt;br /&gt;
		imag = sf_input (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == imag) {&lt;br /&gt;
	if (NULL == real) sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
	/* if only one input, real is in stdin */&lt;br /&gt;
	imag = real;&lt;br /&gt;
	real = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main part of the program reads the real and imaginary parts buffer by buffer and assembles and writes out the complex input. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft= (size_t) (rsize*resize); nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (BUFSIZ &amp;lt; nleft)? BUFSIZ: nleft;&lt;br /&gt;
	sf_charread(rbuf,nbuf,real);&lt;br /&gt;
	sf_charread(ibuf,nbuf,imag);&lt;br /&gt;
	for (i=0; i &amp;lt; nbuf; i += resize) {&lt;br /&gt;
	    memcpy(cbuf+2*i,       rbuf+i,(size_t) resize);&lt;br /&gt;
	    memcpy(cbuf+2*i+resize,ibuf+i,(size_t) resize);&lt;br /&gt;
	}&lt;br /&gt;
	sf_charwrite(cbuf,2*nbuf,cmplx);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
==sfconjgrad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic conjugate-gradient solver for linear inversion &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfconjgrad &amp;lt; dat.rsf mod=mod.rsf &amp;gt; to.rsf &amp;lt; from.rsf &amp;gt; out.rsf niter=1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=1&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is a generic program for least-squares linear&lt;br /&gt;
inversion with the [http://en.wikipedia.org/wiki/Conjugate_gradient_method conjugate-gradient method]. Suppose you have an&lt;br /&gt;
executable program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the&lt;br /&gt;
standard input and produces an RSF file in the standard output. It may&lt;br /&gt;
take any number of additional parameters but one of them must be&lt;br /&gt;
&amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint&lt;br /&gt;
(&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.  The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically&lt;br /&gt;
an RSF program but it could be anything (a script, a multiprocessor&lt;br /&gt;
MPI program, etc.) as long as it implements a linear operator&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint. There are no restrictions on the data&lt;br /&gt;
size or shape. You can easily test the adjointness with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; program searches for a&lt;br /&gt;
vector &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; that minimizes the least-square misfit &lt;br /&gt;
&amp;lt;math&amp;gt;\|\mathbf{d - L\,m}\|^2&amp;lt;/math&amp;gt; for the given input data vector &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The pseudocode for &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is given at the end of the [http://www.reproducibility.org/RSF/book/gee/lsq/paper.pdf &amp;quot;Model fitting with least squares&amp;quot; chapter] of &#039;&#039;Imaging Estimation by Example&#039;&#039; by Jon Claerbout, with the earliest form published in [http://sepwww.stanford.edu/data/media/public/oldreports/sep48/48_25.pdf &amp;quot;Conjugate Gradient Tutorial&amp;quot;] (SEP-48, 1986, same author). A simple toy implementation with a small matrix shows that this is algorithm produces the same steps as the algorithm described in equations 45-49 of [http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf &amp;quot;An introduction to the Conjugate Gradient Method Without the Agonizing Pain&amp;quot;] by J.R. Shewchuk, 1994, when the equation &amp;lt;math&amp;gt;A^T A x = A^T b&amp;lt;/math&amp;gt; (in Shewchuk&#039;s notation) is solved. Multiplying with the transpose ensures a correct solution even when matrix A is square but not symmetric, or not square at all. The program [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad] implements this algorithm for the case when inputs are complex.&lt;br /&gt;
&lt;br /&gt;
Here is an example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test to&lt;br /&gt;
check that the adjoint mode works correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=5.28394&lt;br /&gt;
sfdottest: L&#039;[d]*m=5.28394&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your numbers may be different because &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; generates new&lt;br /&gt;
random input on each run.&lt;br /&gt;
Next, let us make some random data with &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfnoise seed=2005 rep=y &amp;lt; vec.rsf &amp;gt; dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and try to invert the filtering operation using &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfconjgrad sfhelicon filt=flt.rsf lag=lag.rsf mod=vec.rsf &amp;lt; dat.rsf &amp;gt; mod.rsf niter=10&lt;br /&gt;
sfconjgrad: iter 1 of 10&lt;br /&gt;
sfconjgrad: grad=3253.65&lt;br /&gt;
sfconjgrad: iter 2 of 10&lt;br /&gt;
sfconjgrad: grad=289.421&lt;br /&gt;
sfconjgrad: iter 3 of 10&lt;br /&gt;
sfconjgrad: grad=92.3481&lt;br /&gt;
sfconjgrad: iter 4 of 10&lt;br /&gt;
sfconjgrad: grad=36.9417&lt;br /&gt;
sfconjgrad: iter 5 of 10&lt;br /&gt;
sfconjgrad: grad=18.7228&lt;br /&gt;
sfconjgrad: iter 6 of 10&lt;br /&gt;
sfconjgrad: grad=11.1794&lt;br /&gt;
sfconjgrad: iter 7 of 10&lt;br /&gt;
sfconjgrad: grad=7.26941&lt;br /&gt;
sfconjgrad: iter 8 of 10&lt;br /&gt;
sfconjgrad: grad=5.15945&lt;br /&gt;
sfconjgrad: iter 9 of 10&lt;br /&gt;
sfconjgrad: grad=4.23055&lt;br /&gt;
sfconjgrad: iter 10 of 10&lt;br /&gt;
sfconjgrad: grad=3.57495&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output shows that, in 10 iterations, the norm of the gradient vector decreases by almost 1000. &lt;br /&gt;
We can check the residual misfit before&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; dat.rsf sfattr want=norm&lt;br /&gt;
norm value = 49.7801&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and after&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfhelicon filt=flt.rsf lag=lag.rsf &amp;lt; mod.rsf | sfadd scale=1,-1 dat.rsf | sfattr want=norm&lt;br /&gt;
norm value = 5.73563&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In 10 iterations, the misfit decreased by an order of magnitude. The&lt;br /&gt;
result can be improved by running the program for more iterations.&lt;br /&gt;
&lt;br /&gt;
An equivalent implementation for complex-valued inputs is [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad]. A simple, lightweight Python implementation can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/user/fomels/conjgrad.py?view=markup $PYTHONPATH/rsf/conjgrad.py].&lt;br /&gt;
&lt;br /&gt;
==sfcp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Copy or move a dataset.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcp in.rsf out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfcp - copy, sfmv - move.&amp;lt;br&amp;gt;Mimics standard Unix commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmv&amp;lt;/tt&amp;gt; command imitate the Unix&lt;br /&gt;
&amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; commands and serve for copying and moving&lt;br /&gt;
RSF files. Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcp one.rsf two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cp.c?view=markup system/main/cp.c]====&lt;br /&gt;
First, we look for the two first command-line arguments that don&#039;t&lt;br /&gt;
have the &amp;quot;=&amp;quot; character in them and consider them as the names of the&lt;br /&gt;
input and the output files.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are in and out files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == in) {&lt;br /&gt;
		infile = argv[i];&lt;br /&gt;
		in = sf_input (infile);&lt;br /&gt;
	    } else {&lt;br /&gt;
		out = sf_output (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == in || NULL == out)&lt;br /&gt;
	sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we use library functions &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_cp&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_rm&amp;lt;/font&amp;gt; to do the actual work.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_cp(in,out);&lt;br /&gt;
    if (NULL != strstr (sf_getprog(),&amp;quot;mv&amp;quot;)) &lt;br /&gt;
	sf_rm(infile,false,false,false);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcut &amp;lt; in.rsf &amp;gt; out.rsf verb=n [j1=1 j2=1 ... f1=0 f2=0 ... n1=n1 n2=n2 ... max1= max2= ... min1= min2= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | jN defines the jump in N-th dimension&amp;lt;br&amp;gt;fN is the window start&amp;lt;br&amp;gt;nN is the window size&amp;lt;br&amp;gt;minN and maxN is the maximum and minimum in N-th dimension&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Reverse of window. &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcut&amp;lt;/tt&amp;gt; command is related to &amp;lt;tt&amp;gt;sfwindow&amp;lt;/tt&amp;gt; and has the same&lt;br /&gt;
set of arguments only instead of extracting the selected window, it fills it&lt;br /&gt;
with zeroes. The size of the input data is preserved. &lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; in.rsf&lt;br /&gt;
bash$ &amp;lt; in.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut n1=2 f1=1 n2=3 f2=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            0            0            1            1&lt;br /&gt;
  15:             1            0            0            1            1&lt;br /&gt;
  20:             1            0            0            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut j1=2 | sfdisfil&lt;br /&gt;
   0:             0            1            0            1            0&lt;br /&gt;
   5:             0            1            0            1            0&lt;br /&gt;
  10:             0            1            0            1            0&lt;br /&gt;
  15:             0            1            0            1            0&lt;br /&gt;
  20:             0            1            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfdd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert between different formats. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdd &amp;lt; in.rsf &amp;gt; out.rsf line=8 form= type= format=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;form=&#039;&#039;&#039; ||   || 	ascii, native, xdr&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Element format (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;line=8&#039;&#039;&#039; ||   || 	Number of numbers per line (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	int, float, complex&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; program is used to change either the form (&amp;lt;tt&amp;gt;ascii&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;native&amp;lt;/tt&amp;gt;) or the type (&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt;) of the input dataset. &lt;br /&gt;
In the example below, we create a plain text (ASCII) file with numbers and&lt;br /&gt;
then use &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; to generate an RSF file in &amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt; form with&lt;br /&gt;
&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt; numbers. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cat test.txt&lt;br /&gt;
1 2 3 4 5 6&lt;br /&gt;
bash$ echo n1=6 data_format=ascii_int in=test.txt &amp;gt; test.rsf&lt;br /&gt;
bash$ sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;test.txt&amp;quot;&lt;br /&gt;
    esize=0 type=int form=ascii&lt;br /&gt;
    n1=6           d1=?           o1=?&lt;br /&gt;
        6 elements&lt;br /&gt;
bash$ sfdd &amp;lt; test.rsf form=xdr type=complex &amp;gt; test2.rsf&lt;br /&gt;
bash$ sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=xdr&lt;br /&gt;
    n1=3           d1=?           o1=?&lt;br /&gt;
        3 elements 24 bytes&lt;br /&gt;
bash$ sfdisfil &amp;lt; test2.rsf&lt;br /&gt;
   0:          1,         2i         3,         4i         5,         6i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To learn more about the RSF data format, consult the [[Guide to RSF file format| guide to RSF format]].&lt;br /&gt;
&lt;br /&gt;
==sfdisfil==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Print out data values.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdisfil &amp;lt; in.rsf number=y col=0 format= header= trailer=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Alternatively, use sfdd and convert to ASCII form.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;col=0&#039;&#039;&#039; ||   || 	Number of columns.&lt;br /&gt;
:The default depends on the data type:&lt;br /&gt;
:10 for int and char,&lt;br /&gt;
:5 for float,&lt;br /&gt;
:3 for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Format for numbers (printf-style).&lt;br /&gt;
:The default depends on the data type:&amp;lt;br&amp;gt;       &amp;quot;%4d &amp;quot; for int and char,&amp;lt;br&amp;gt;       &amp;quot;%13.4g&amp;quot; for float,&amp;lt;br&amp;gt;       &amp;quot;%10.4g,%10.4gi&amp;quot; for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;header=&#039;&#039;&#039; ||   || 	Optional header string to output before data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;number=y&#039;&#039;&#039; ||  [y/n] || 	If number the elements&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;trailer=&#039;&#039;&#039; ||   || 	Optional trailer string to output after data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; program simply dumps the data contents to the standard&lt;br /&gt;
output in a text form. It is used mostly for debugging purposes to quickly&lt;br /&gt;
examine RSF files. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath o1=0 d1=2 n1=12 output=x1 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
  10:            20           22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output format is easily configurable.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil col=6 number=n format=&amp;quot;%5.1f&amp;quot;&lt;br /&gt;
  0.0  2.0  4.0  6.0  8.0 10.0&lt;br /&gt;
 12.0 14.0 16.0 18.0 20.0 22.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Along with &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; provides a simple way to convert&lt;br /&gt;
RSF data to an ASCII form.&lt;br /&gt;
&lt;br /&gt;
==sfdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; is a generic dot-product test program for testing&lt;br /&gt;
linear operators. Suppose there is an executable program&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the standard input and&lt;br /&gt;
produces an RSF file in the standard output. It may take any number of&lt;br /&gt;
additional parameters but one of them must be &amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets&lt;br /&gt;
the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint (&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.&lt;br /&gt;
The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically an RSF program but it could&lt;br /&gt;
be anything (a script, a multiprocessor MPI program, etc.) as long as&lt;br /&gt;
it implements a linear operator &amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}^T&amp;lt;/math&amp;gt;. The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program is testing the equality&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
d^T\,L\,m = m^T\,L^T\,d&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
by using random vectors &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. You can invoke it with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest &amp;lt;prog&amp;gt; [optional aruments] mod=mod.rsf dat=dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;mod.rsf&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;dat.rsf&amp;lt;/tt&amp;gt; are RSF files that&lt;br /&gt;
represent vectors from the model and data spaces. Pay attention to the &lt;br /&gt;
dimension and size of these vectors! If the program does not respond&lt;br /&gt;
for a very long time, it is quite possible that the dimension and size&lt;br /&gt;
of the vectors are inconsistent with the requirement of the program to be&lt;br /&gt;
tested. &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;&lt;br /&gt;
does not create any temporary files and does not have any restrictive&lt;br /&gt;
limitations on the size of the vectors.&lt;br /&gt;
Here is an example. We first setup a vector with 100 elements using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; and then run &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; to test the&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; program. &amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; implements a linear&lt;br /&gt;
operator of causal integration and its adjoint, the anti-causal&lt;br /&gt;
integration.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 &amp;gt; vec.rsf&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1410.2&lt;br /&gt;
sfdottest: L&#039;[d]*m=1410.2&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1165.87&lt;br /&gt;
sfdottest: L&#039;[d]*m=1165.87&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The numbers are different on subsequent runs because of changing&lt;br /&gt;
seed in the random number generator.&lt;br /&gt;
Here is a somewhat more complicated example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now the &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=8.97375&lt;br /&gt;
sfdottest: L&#039;[d]*m=8.97375&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is the same program tested in the inverse filtering mode:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf div=y&lt;br /&gt;
sfdottest:  L[m]*d=15.0222&lt;br /&gt;
sfdottest: L&#039;[d]*m=15.0222&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfget==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Output parameters from the header.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfget &amp;lt; in.rsf parform=y par1 par2 ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;parform=y&#039;&#039;&#039; ||  [y/n] || 	If y, print out parameter=value. If n, print out value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt; program extracts a parameter value from an RSF file. It is&lt;br /&gt;
useful mostly for scripting. Here is, for example, a quick calculation of the&lt;br /&gt;
maximum value on the first axis in an RSF dataset (the output of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;) using the standard Unix &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt; calculator.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ ( sfspike n1=100 | sfget n1 d1 o1; echo &amp;quot;o1+(n1-1)*d1&amp;quot; ) | bc&lt;br /&gt;
.396&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See also &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/get.c?view=markup system/main/get.c]====&lt;br /&gt;
The implementation is trivial. Loop through all command-line parameters that contain &lt;br /&gt;
the &amp;quot;=&amp;quot; character.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i = 1; i &amp;lt; argc; i++) {&lt;br /&gt;
	key = argv[i];&lt;br /&gt;
	if (NULL != strchr(key,&#039;=&#039;)) continue;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the parameter value (as string) and output it as either&lt;br /&gt;
&amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, depending on the&lt;br /&gt;
&amp;lt;tt&amp;gt;parform&amp;lt;/tt&amp;gt; parameter.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	string = sf_histstring(in,key);&lt;br /&gt;
	if (NULL == string) {&lt;br /&gt;
	    sf_warning(&amp;quot;No key %s&amp;quot;,key);&lt;br /&gt;
	} else {&lt;br /&gt;
	    if (parform) printf (&amp;quot;%s=&amp;quot;,key);&lt;br /&gt;
	    printf(&amp;quot;%s\n&amp;quot;,string);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheadercut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadercut mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array of size n2.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; is close to &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; but instead&lt;br /&gt;
of windowing the dataset, it fills the traces specified by the header&lt;br /&gt;
mask with zeroes. The size of the input data is preserved.&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for &lt;br /&gt;
zeroing every other trace in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a mask with alternating ones and zeros using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 mag=1 | sfdd type=int &amp;gt; ones.rsf&lt;br /&gt;
bash$ sfspike n1=5 mag=0 | sfdd type=int &amp;gt; zeros.rsf&lt;br /&gt;
bash$ sfinterleave axis=1 ones.rsf zeros.rsf &amp;gt; mask.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; mask.rsf&lt;br /&gt;
   0:    1    0    1    0    1    0    1    0    1    0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, &amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; zeros the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfheadercut &amp;lt; input.rsf mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; output.rsf &lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             0            0            0            0            0&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             0            0            0            0            0&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfheadersort==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Sort a dataset according to a header key. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadersort &amp;lt; in.rsf &amp;gt; out.rsf head=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;head=&#039;&#039;&#039; ||   || 	header file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is used to sort traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; for randomly shuffling traces in the input&lt;br /&gt;
file. First, let us create an input file with seven traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=7 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with seven header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=7 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:       0.05256      -0.2879       0.1487       0.4097       0.1548&lt;br /&gt;
   5:        0.4501       0.2836&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally, we&lt;br /&gt;
apply &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; to shuffle the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheadersort head=random.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             5            5            5            5            5&lt;br /&gt;
  20:             7            7            7            7            7&lt;br /&gt;
  25:             4            4            4            4            4&lt;br /&gt;
  30:             6            6            6            6            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As expected, the order of traces in the output file corresponds to the&lt;br /&gt;
order of values in the header. Thanks to the separation between&lt;br /&gt;
headers and data, the operation of &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is optimally&lt;br /&gt;
efficient. It first sorts the headers and only then accesses the data,&lt;br /&gt;
reading each data trace only once.&lt;br /&gt;
&lt;br /&gt;
==sfheaderwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderwindow mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array os size n2, windowed is n1xm2,&amp;lt;br&amp;gt;where m2 is the number of nonzero elements in mask.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is used to window traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for randomly&lt;br /&gt;
selecting part of the traces in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with ten header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:     -0.005768      0.02258     -0.04331      -0.4129      -0.3909&lt;br /&gt;
   5:      -0.03582       0.4595      -0.3326        0.498      -0.3517&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally,&lt;br /&gt;
we apply &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; to window the input traces selecting&lt;br /&gt;
only those for which the header is greater than zero.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; random.rsf sfmask min=0 &amp;gt; mask.rsf&lt;br /&gt;
bash$ &amp;lt; mask.rsf sfdisfil&lt;br /&gt;
   0:    0    1    0    0    0    0    1    0    1    0&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheaderwindow mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             7            7            7            7            7&lt;br /&gt;
  10:             9            9            9            9            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, only three traces are selected for the output. Thanks to&lt;br /&gt;
the separation between headers and data, the operation of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is optimally efficient. &lt;br /&gt;
&lt;br /&gt;
==sfin==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display basic information about RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfin info=y check=2. trail=y file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | n1,n2,... are data dimensions&amp;lt;br&amp;gt;o1,o2,... are axis origins&amp;lt;br&amp;gt;d1,d2,... are axis sampling intervals&amp;lt;br&amp;gt;label1,label2,... are axis labels&amp;lt;br&amp;gt;unit1,unit2,... are axis units&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;check=2.&#039;&#039;&#039; ||   || 	Portion of the data (in Mb) to check for zero values.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;info=y&#039;&#039;&#039; ||  [y/n] || 	If n, only display the name of the data file.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trail=y&#039;&#039;&#039; ||  [y/n] || 	If n, skip trailing dimensions of  one&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; is one of the most useful programs for operating with&lt;br /&gt;
RSF files. It produces quick information on the file hypercube&lt;br /&gt;
dimensions and checks the consistency of the associated data file.&lt;br /&gt;
Here is an example. Let us create an RSF file and examine it with &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=20 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=100         d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        2000 elements 8000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; reports the following information:&lt;br /&gt;
  &lt;br /&gt;
*location of the data file (&amp;lt;tt&amp;gt;/tmp/spike.rsf\@&amp;lt;/tt&amp;gt;) &lt;br /&gt;
*element size (4 bytes) &lt;br /&gt;
*element type (floating point) &lt;br /&gt;
*element form (native) &lt;br /&gt;
*hypercube dimensions (100 by 20) &lt;br /&gt;
*axes scale (0.004 and 0.1) &lt;br /&gt;
*axes origin (0 and 0) &lt;br /&gt;
*axes labels &lt;br /&gt;
*axes units &lt;br /&gt;
*total number of elements &lt;br /&gt;
*total number of bytes in the data file &lt;br /&gt;
Suppose that the file got corrupted by a buggy program and reports&lt;br /&gt;
incorrect dimensions. The &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; program should be able to&lt;br /&gt;
catch the discrepancy.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo n2=100 &amp;gt;&amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf &amp;gt; /dev/null&lt;br /&gt;
sfin:           Actually 8000 bytes, 20% of expected.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; also checks the first records in the file for zeros. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=100 k2=99 &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 32768 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The number of bytes to check is adjustable&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike2.rsf check=0.01 &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 16384 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can also output only the location of the data file. This is&lt;br /&gt;
sometimes handy in scripts.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike.rsf spike2.rsf info=n&lt;br /&gt;
/tmp/spike.rsf@ /tmp/spike2.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An alternative is to use &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfget parform=n in &amp;lt; spike.rsf&lt;br /&gt;
/tmp/spike.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To actually eliminate annoying trailing dimensions of length one (not just stop displaying them with &amp;lt;tt&amp;gt;trail=n&amp;lt;/tt&amp;gt;), you may use &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt;. Example for eliminating axis 6:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sed -i &#039;s/n6=1//g&#039; file.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfinterleave==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Combine several datasets by interleaving.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfinterleave &amp;gt; out.rsf axis=3 [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis for interleaving&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt; combines two or more datasets by interleaving them on one&lt;br /&gt;
of the axes. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ sfscale &amp;lt; one.rsf dscale=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; two.rsf&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             2            2            2            2            2&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             2            2            2            2            2&lt;br /&gt;
bash$ sfinterleave one.rsf two.rsf axis=1 | sfdisfil&lt;br /&gt;
   0:             1            2            1            2            1&lt;br /&gt;
   5:             2            1            2            1            2&lt;br /&gt;
  10:             1            2            1            2            1&lt;br /&gt;
  15:             2            1            2            1            2&lt;br /&gt;
  20:             1            2            1            2            1&lt;br /&gt;
  25:             2            1            2            1            2&lt;br /&gt;
  30:             1            2            1            2            1&lt;br /&gt;
  35:             2            1            2            1            2&lt;br /&gt;
  40:             1            2            1            2            1&lt;br /&gt;
  45:             2            1            2            1            2&lt;br /&gt;
bash$ sfinterleave &amp;lt; one.rsf two.rsf axis=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
  25:             2            2            2            2            2&lt;br /&gt;
  30:             1            1            1            1            1&lt;br /&gt;
  35:             2            2            2            2            2&lt;br /&gt;
  40:             1            1            1            1            1&lt;br /&gt;
  45:             2            2            2            2            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmask==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmask &amp;lt; in.rsf &amp;gt; out.rsf min=-FLT_MAX max=+FLT_MAX&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Mask is an integer data with ones and zeros. &amp;lt;br&amp;gt;Ones correspond to input values between min and max.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The output can be used with sfheaderwindow.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=+FLT_MAX&#039;&#039;&#039; ||   || 	maximum header value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=-FLT_MAX&#039;&#039;&#039; ||   || 	minimum header value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmask&amp;lt;/tt&amp;gt; creates an integer output of ones and zeros comparing&lt;br /&gt;
the values of the input data to specified &amp;lt;tt&amp;gt;min=&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;max=&amp;lt;/tt&amp;gt; parameters. It is useful for &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; and&lt;br /&gt;
in many other applications. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 output=&amp;quot;sin(x1)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdisfil&lt;br /&gt;
   0:             0       0.8415       0.9093       0.1411      -0.7568&lt;br /&gt;
   5:       -0.9589      -0.2794        0.657       0.9894       0.4121&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfmask min=-0.5 max=0.5 | sfdisfil&lt;br /&gt;
   0:    1    0    0    1    0    0    1    0    0    1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations on data files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmath &amp;gt; out.rsf type= unit= output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs, conj (for complex data).&amp;lt;br&amp;gt;                 &amp;lt;br&amp;gt;sfmath will work on float or complex data, but all the input and output&amp;lt;br&amp;gt;files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfmath is sfadd, which may be more efficient, but is&amp;lt;br&amp;gt;less versatile.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Examples:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfmath x=file1.rsf y=file2.rsf power=file3.rsf output=&#039;sin((x+2*y)^power)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath &amp;lt; file1.rsf tau=file2.rsf output=&#039;exp(tau*input)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath n1=100 type=complex output=&amp;quot;exp(I*x1)&amp;quot; &amp;gt; out.rsf&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Mathematical description of the output&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	output data type [float,complex]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; is a versatile program for mathematical operations&lt;br /&gt;
with RSF files. It can operate with several input file, all of the&lt;br /&gt;
same dimensions and data type. The data type can be real (floating&lt;br /&gt;
point) or complex. Here is an example that demonstrates several&lt;br /&gt;
features of &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 \&lt;br /&gt;
output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; &amp;gt; rad.rsf&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfrtoc | sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
bash$ &amp;lt; rose.rsf sfgraph title=Rose screenratio=1 wantaxis=n | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first line creates a 2-D dataset that consists of 40 traces 629&lt;br /&gt;
samples each. The values of the data are computed with the formula&lt;br /&gt;
&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
coordinate on the first axis, and &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt; is the coordinate of the&lt;br /&gt;
second axis. In the second line, we convert the data from real to&lt;br /&gt;
complex using &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; and produce a complex dataset using&lt;br /&gt;
formula &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;input*exp(I*x1)&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
input file. Finally, we plot the complex data as a collection of&lt;br /&gt;
parametric curves using &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt; and display the result using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpen&amp;lt;/tt&amp;gt;.  The plot appearing on your screen should look similar&lt;br /&gt;
to the figure.&lt;br /&gt;
[[Image:rose.png|frame|center|This figure was created with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
One possible alternative to the second line above is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfmath output=x1 &amp;gt; ang.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*cos(a)&amp;quot; &amp;gt; cos.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*sin(a)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ sfcmplx cos.rsf sin.rsf &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we refer to input files by names (&amp;lt;tt&amp;gt;r&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;) and combine the names in a formula.&lt;br /&gt;
&lt;br /&gt;
==sfpad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Pad a dataset with zeros.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpad &amp;lt; in.rsf &amp;gt; out.rsf [beg1= beg2= ... end1= end2=... | n1=  n2 = ... | n1out= n2out= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | begN specifies the number of zeros to add before the beginning of axis N.&amp;lt;br&amp;gt;endN specifies the number of zeros to add after the end of axis N.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternatively:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nN or nNout specify the output length of axis N, padding occurs at the end.&amp;lt;br&amp;gt;nN and nNout are equivalent.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;pad&amp;lt;/tt&amp;gt; increases the dimensions of the input dataset by padding&lt;br /&gt;
the data with zeroes. Here are some simple examples.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad n2=5 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=2 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=1 end2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfwindow n1=3 | sfpad n1=5 n2=5 beg1=1 beg2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            1            1            1            0&lt;br /&gt;
  10:             0            1            1            1            0&lt;br /&gt;
  15:             0            1            1            1            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can use &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; to pad data with values other than zeroes.&lt;br /&gt;
&lt;br /&gt;
==sfput==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Input parameters into a header. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfput &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is a very simple program. It simply appends parameters&lt;br /&gt;
from the command line to the output RSF file. One can achieve similar&lt;br /&gt;
results with editing by hand or with standard Unix utilities like&lt;br /&gt;
&amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is sometimes more&lt;br /&gt;
convenient because it handles input/output operations similarly to&lt;br /&gt;
other regular RSF programs.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash$ sfput &amp;lt; spike.rsf d1=25 label1=Depth unit1=m &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf&lt;br /&gt;
spike2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=25          o1=0          label1=&amp;quot;Depth&amp;quot; unit1=&amp;quot;m&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreal==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreal &amp;lt; cmplx.rsf &amp;gt; real.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; extracts the real part of a complex type dataset. The&lt;br /&gt;
imaginary part can be extracted with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;, an the real&lt;br /&gt;
and imaginary part can be combined together with &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Here is a simple example. Let us first create a complex dataset &lt;br /&gt;
with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 type=complex output=&amp;quot;(2+I)*x1&amp;quot; &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ fdisfil &amp;lt; cmplx.rsf&lt;br /&gt;
   0:          0,         0i         2,         1i         4,         2i&lt;br /&gt;
   3:          6,         3i         8,         4i        10,         5i&lt;br /&gt;
   6:         12,         6i        14,         7i        16,         8i&lt;br /&gt;
   9:         18,         9i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the real part with &amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfreal &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the imaginary part with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfimag &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             5            6            7            8            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreverse==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Reverse one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreverse &amp;lt; in.rsf &amp;gt; out.rsf which=-1 verb=false memsize=sf_memsize() opt=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;opt=&#039;&#039;&#039; ||   || 	If y, change o and d parameters on the reversed axis;&lt;br /&gt;
:if i, don&#039;t change o and d&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;which=-1&#039;&#039;&#039; ||   || 	Which axis to reverse.&lt;br /&gt;
:To reverse a given axis, start with 0,&lt;br /&gt;
:add 1 to number to reverse n1 dimension,&lt;br /&gt;
:add 2 to number to reverse n2 dimension,&lt;br /&gt;
:add 4 to number to reverse n3 dimension, etc.&lt;br /&gt;
:Thus, which=7 would reverse the first three dimensions,&lt;br /&gt;
:which=5 just n1 and n3, etc.&lt;br /&gt;
:which=0 will just pass the input on through unchanged.&lt;br /&gt;
|}&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfreverse&amp;lt;/tt&amp;gt;. First, let us create a&lt;br /&gt;
2-D dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the first axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfdisfil&lt;br /&gt;
   0:             4            3            2            1            0&lt;br /&gt;
   5:             5            4            3            2            1&lt;br /&gt;
  10:             6            5            4            3            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=2 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=3 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;which=&amp;lt;/tt&amp;gt; parameter controls the axes that are&lt;br /&gt;
being reversed by encoding them into one number.&lt;br /&gt;
When an axis is reversed, what happens with its axis origin and&lt;br /&gt;
sampling parameters? This behavior is controlled by &amp;lt;tt&amp;gt;opt=&amp;lt;/tt&amp;gt;. In&lt;br /&gt;
our example,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfget n1 o1 d1&lt;br /&gt;
n1=5&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfget o1 d1&lt;br /&gt;
o1=4&lt;br /&gt;
d1=-1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The default behavior (equivalent to &amp;lt;tt&amp;gt;opt=y&amp;lt;/tt&amp;gt;) puts the origin&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; at the end of the axis and reverses the sampling parameter&lt;br /&gt;
&amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;.  Using &amp;lt;tt&amp;gt;opt=n&amp;lt;/tt&amp;gt; preserves the sampling but reverses&lt;br /&gt;
the origin.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=n | sfget o1 d1&lt;br /&gt;
o1=-4&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Using &amp;lt;tt&amp;gt;opt=i&amp;lt;/tt&amp;gt; preserves both the sampling and the origin while&lt;br /&gt;
reversing the axis.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=i | sfget o1 d1&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
One of the three possible behaviors may be desirable depending on the&lt;br /&gt;
application.&lt;br /&gt;
&lt;br /&gt;
==sfrm==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Remove RSF files together with their data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrm file1.rsf [file2.rsf ...] [-i] [-v] [-f] &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Mimics the standard Unix rm command.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfmv, sfcp.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; is a program for removing RSF files. Its arguments mimic&lt;br /&gt;
the arguments of the standard Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt; utility: &amp;lt;tt&amp;gt;-v&amp;lt;/tt&amp;gt;&lt;br /&gt;
for verbosity, &amp;lt;tt&amp;gt;-i&amp;lt;/tt&amp;gt; for interactive inquiry, &amp;lt;tt&amp;gt;-f&amp;lt;/tt&amp;gt; for&lt;br /&gt;
force removal of suspicious files. Unlike the Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; removes both the RSF header files and the binary files&lt;br /&gt;
that the headers point to. &lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 &amp;gt; spike.rsf datapath=./&lt;br /&gt;
bash&amp;amp;#36; sfget in &amp;lt; spike.rsf&lt;br /&gt;
in=./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
spike.rsf  spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; sfrm -v spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing header spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing data ./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
ls: No match.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sfrotate==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Rotate a portion of one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrotate &amp;lt; in.rsf &amp;gt; out.rsf verb=n memsize=sf_memsize() rot#=(0,0,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rot#=(0,0,...)&#039;&#039;&#039; ||   || 	length of #-th axis that is moved to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt; modifies the input dataset by splitting it into&lt;br /&gt;
parts and putting the parts back in a different order. Here is a quick example.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the first axis by putting the last two columns in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=2 | sfdisfil&lt;br /&gt;
   0:             3            4            0            1            2&lt;br /&gt;
   5:             4            5            1            2            3&lt;br /&gt;
  10:             5            6            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the second axis by putting the last row in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot2=1 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=3 rot2=1 | sfdisfil&lt;br /&gt;
   0:             4            5            6            2            3&lt;br /&gt;
   5:             2            3            4            0            1&lt;br /&gt;
  10:             3            4            5            1            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The transformation is shown schematically in Figure~(fig:rotate).&lt;br /&gt;
[[Image:rotate.png|frame|center|Schematic transformation of data with &amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
&lt;br /&gt;
==sfrtoc==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;See also: sfcmplx&lt;br /&gt;
|}&lt;br /&gt;
The input to &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; can be any &amp;lt;tt&amp;gt;type=float&amp;lt;/tt&amp;gt; dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 n2=20 n3=30 &amp;gt;real.rsf&lt;br /&gt;
bash$ sfin real.rsf&lt;br /&gt;
real.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/real.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output dataset will have &amp;lt;tt&amp;gt;type=complex&amp;lt;/tt&amp;gt;, and its binary will be twice the size of the input:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt;real.rsf sfrtoc &amp;gt;complex.rsf&lt;br /&gt;
bash$ sfin complex.rsf &lt;br /&gt;
complex.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/complex.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 48000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfscale==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Scale data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfscale &amp;lt; in.rsf &amp;gt; out.rsf axis=0 rscale=0. dscale=1.&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;To scale by a constant factor, you can also use sfmath or sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=0&#039;&#039;&#039; ||   || 	Scale by maximum in the dimensions up to this axis.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dscale=1.&#039;&#039;&#039; ||   || 	Scale by this factor (works if rscale=0)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;rscale=0.&#039;&#039;&#039; ||   || 	Scale by this factor.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfscale&amp;lt;/tt&amp;gt; scales the input dataset by a factor. Here&lt;br /&gt;
are some simple examples. First, let us create a test dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil   &lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Scale every data point by 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale dscale=2 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
   5:             4            8           12           16           20&lt;br /&gt;
  10:             6           12           18           24           30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide every trace by its maximum value:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=1 | sfdisfil&lt;br /&gt;
   0:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
   5:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide by the maximum value in the whole 2-D dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=2 | sfdisfil&lt;br /&gt;
   0:       0.06667       0.1333          0.2       0.2667       0.3333&lt;br /&gt;
   5:        0.1333       0.2667          0.4       0.5333       0.6667&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;rscale=&amp;lt;/tt&amp;gt; parameter is synonymous to &amp;lt;tt&amp;gt;dscale=&amp;lt;/tt&amp;gt; except&lt;br /&gt;
when it is equal to zero. With &amp;lt;tt&amp;gt;sfscale dscale=0&amp;lt;/tt&amp;gt;, the dataset gets&lt;br /&gt;
multiplied by zero. If using &amp;lt;tt&amp;gt;rscale=0&amp;lt;/tt&amp;gt;, the other parameters are&lt;br /&gt;
used to define scaling.  Thus, &amp;lt;tt&amp;gt;sfscale rscale=0 axis=1&amp;lt;/tt&amp;gt; is&lt;br /&gt;
equivalent to &amp;lt;tt&amp;gt;sfscale axis=1&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfscale rscale=0&amp;lt;/tt&amp;gt;&lt;br /&gt;
is equivalent to &amp;lt;tt&amp;gt;sfscale dscale=1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfspike==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate simple data: spikes, boxes, planes, constants. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspike &amp;gt; spike.rsf mag= nsp=1 k#=[0,...] l#=[k1,k2,...] p#=[0,...] n#= o#=[0,0,...] d#=[0.004,0.1,0.1,...] label#=[Time,Distance,Distance,...] unit#=[s,km,km,...] title=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Spike positioning is given in samples and starts with 1.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=[0.004,0.1,0.1,...]&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;k#=[0,...]&#039;&#039;&#039; ||   || 	spike starting position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;l#=[k1,k2,...]&#039;&#039;&#039; ||   || 	spike ending position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=[Time,Distance,Distance,...]&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;mag=&#039;&#039;&#039; ||   || 	spike magnitudes  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nsp=1&#039;&#039;&#039; ||   || 	Number of spikes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o#=[0,0,...]&#039;&#039;&#039; ||   || 	origin on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;p#=[0,...]&#039;&#039;&#039; ||   || 	spike inclination (in samples)  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || 	title for plots&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=[s,km,km,...]&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; takes no input and generates an output with&lt;br /&gt;
&amp;quot;spikes&amp;quot;. It is an easy way to create data. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 k2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The spike location is specified by parameters &amp;lt;tt&amp;gt;k1=4&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;k2=1&amp;lt;/tt&amp;gt;. Note that the locations are numbered starting from 1. &lt;br /&gt;
If one of the parameters is omitted or given the value of zero, the &lt;br /&gt;
spike in the corresponding direction becomes a plane:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 | sfdisfil   &lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            1            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If no spike parameters are given, the whole dataset is filled with ones:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create several spikes, use the &amp;lt;tt&amp;gt;nsp=&amp;lt;/tt&amp;gt; parameter and give a comma-separated list of values to &amp;lt;tt&amp;gt;k#=&amp;lt;/tt&amp;gt; arguments:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the number of values in the list is smaller than &amp;lt;tt&amp;gt;nsp&amp;lt;/tt&amp;gt;, the&lt;br /&gt;
last value gets repeated, and the spikes add on top of each other,&lt;br /&gt;
creating larger amplitudes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3 k2=1,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            2            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The magnitude of the spikes can be controlled explicitly with the&lt;br /&gt;
&amp;lt;tt&amp;gt;mag=&amp;lt;/tt&amp;gt; parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 mag=1,4,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            4            0            0&lt;br /&gt;
  10:             0            0            0            2            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can create boxes instead of spikes by using &amp;lt;tt&amp;gt;l#=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 l1=4 k2=2 mag=8 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            8            8            8            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, &amp;lt;tt&amp;gt;k1=2&amp;lt;/tt&amp;gt; specifies the box start, and &amp;lt;tt&amp;gt;l1=4&amp;lt;/tt&amp;gt;&lt;br /&gt;
specifies the box end.&lt;br /&gt;
Finally, multi-dimensional planes can be given an inclination by using &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=1 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; interprets the &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters in stepout from sample to sample, not in terms of axes units (i.e. s/m). &lt;br /&gt;
&lt;br /&gt;
More than one p parameter can be specified. In this case, a (hyper) plane will be created.&lt;br /&gt;
&lt;br /&gt;
When the inclination value is not integer, simple linear interpolation is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=0.7 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0          0.3          0.7            0            0&lt;br /&gt;
  10:             0            0          0.6          0.4            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; supplies default dimensions and labels to all axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the first axis is assumed to be time, with sampling of&lt;br /&gt;
&amp;lt;math&amp;gt;0.004&amp;lt;/math&amp;gt; seconds. All other axes are assumed to be distance, with&lt;br /&gt;
sampling of &amp;lt;math&amp;gt;0.1&amp;lt;/math&amp;gt; kilometers. All these parameters can be changed on&lt;br /&gt;
the command line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 label3=Offset unit3=ft d3=20 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=20          o3=0          label3=&amp;quot;Offset&amp;quot; unit3=&amp;quot;ft&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfspray==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extend a dataset by duplicating in the specified axis dimension.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspray &amp;lt; in.rsf &amp;gt; out.rsf axis=2 n= d= o= label= unit=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    This operation is adjoint to sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to spray&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d=&#039;&#039;&#039; ||   || 	Sampling of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	Label of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n=&#039;&#039;&#039; ||   || 	Size of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o=&#039;&#039;&#039; ||   || 	Origin of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	Units of the newly created dimension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; extends the input hypercube by replicating the data&lt;br /&gt;
in one of the dimensions. The output dataset acquires one additional&lt;br /&gt;
dimension. Here is an example:&lt;br /&gt;
Start with a 2-D dataset&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=2 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extend the data in the second dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=2 n=3 &amp;gt; test2.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=3           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=1           o3=0          &lt;br /&gt;
        30 elements 120 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test2.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
  20:             1            2            3            4            5&lt;br /&gt;
  25:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is three-dimensional, with traces from the original&lt;br /&gt;
data duplicated along the second axis.&lt;br /&gt;
Extend the data in the third dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=3 n=2 &amp;gt; test3.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test3.rsf&lt;br /&gt;
test3.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test3.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=?           o3=?          &lt;br /&gt;
        20 elements 80 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test3.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is also three-dimensional, with the original data replicated&lt;br /&gt;
along the third axis.&lt;br /&gt;
&lt;br /&gt;
==sfstack==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stack a dataset over one of the dimensions.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstack &amp;lt; in.rsf &amp;gt; out.rsf axis=2 rms=n norm=y min=n max=n&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;This operation is adjoint to sfspray.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to stack&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;max=n&#039;&#039;&#039; ||  [y/n] || 	If y, find maximum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;min=n&#039;&#039;&#039; ||  [y/n] || 	If y, find minimum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	If y, normalize by fold.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rms=n&#039;&#039;&#039; ||  [y/n] || 	If y, compute the root-mean-square instead of stack.&lt;br /&gt;
|}&lt;br /&gt;
While &amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; adds a dimension to a hypercube,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; effectively removes one of the dimensions by stacking&lt;br /&gt;
over it. Here are some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=2 | sfdisfil&lt;br /&gt;
   0:           1.5            2            3            4            5&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 | sfdisfil&lt;br /&gt;
   0:           2.5            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Why is the first value not 1 (in the first case) or 2 (in the second&lt;br /&gt;
case)? By default, &amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; normalizes the stack by the fold&lt;br /&gt;
(the number of non-zero entries). To avoid normalization, use&lt;br /&gt;
&amp;lt;tt&amp;gt;norm=n&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack norm=n | sfdisfil &lt;br /&gt;
   0:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; can also compute root-mean-square values as &lt;br /&gt;
well as minimum and maximum values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack rms=y | sfdisfil&lt;br /&gt;
   0:         1.581         2.16        3.109        4.082        5.066&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack min=y | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 max=y | sfdisfil &lt;br /&gt;
   0:             4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sftransp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Transpose two axes in a dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sftransp &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() plane=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;If you get a &amp;quot;Cannot allocate memory&amp;quot; error, give the program a&amp;lt;br&amp;gt;memsize=1 command-line parameter to force out-of-core operation.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plane=&#039;&#039;&#039; ||   || 	Two-digit number with axes to transpose. The default is 12&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; program transposes the input hypercube&lt;br /&gt;
exchanging the two axes specified by the &amp;lt;b&amp;gt;plane=&amp;lt;/b&amp;gt; parameter. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 n2=20 n3=30 &amp;gt; orig123.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin orig123.rsf &lt;br /&gt;
orig123.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/orig123.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=23 &amp;gt;out132.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out132.rsf &lt;br /&gt;
out132.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=30          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=20          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=13 &amp;gt;out321.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out321.rsf &lt;br /&gt;
out321.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=30          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=10          d3=0.004       o3=0          label3=&amp;quot;Time&amp;quot; unit3=&amp;quot;s&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; tries to fit the dataset in memory to transpose it&lt;br /&gt;
there but, if not enough memory is available, it performs a slower&lt;br /&gt;
transpose out of core using disk operations. You can control the&lt;br /&gt;
amount of available memory using the &amp;lt;b&amp;gt;memsize=&amp;lt;/b&amp;gt; parameter or&lt;br /&gt;
the &amp;lt;b&amp;gt;RSFMEMSIZE&amp;lt;/b&amp;gt; environmental variable.&lt;br /&gt;
&lt;br /&gt;
==sfwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwindow &amp;lt; in.rsf &amp;gt; out.rsf verb=n squeeze=y j#=(1,...) d#=(d1,d2,...) f#=(0,...) min#=(o1,o2,,...) n#=(0,...) max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(d1,d2,...)&#039;&#039;&#039; ||   || 	sampling in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;f#=(0,...)&#039;&#039;&#039; ||   || 	window start in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;j#=(1,...)&#039;&#039;&#039; ||   || 	jump in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&#039;&#039;&#039; ||   || 	maximum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min#=(o1,o2,,...)&#039;&#039;&#039; ||   || 	minimum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=(0,...)&#039;&#039;&#039; ||   || 	window size in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;squeeze=y&#039;&#039;&#039; ||  [y/n] || 	if y, squeeze dimensions equal to 1 to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; is used to window a portion of the dataset. Here is&lt;br /&gt;
a quick example: Start by creating some data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now window the first two rows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n2=2 | sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the first three columns:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n1=3 | sfdisfil&lt;br /&gt;
   0:             1            2            3            2            4&lt;br /&gt;
   5:             6            3            6            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the middle row:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can interpret the &amp;lt;b&amp;gt;f#&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;n#&amp;lt;/b&amp;gt; parameters as&lt;br /&gt;
meaning &amp;quot;skip that many rows/columns&amp;quot; and &amp;quot;select that many&lt;br /&gt;
rows/columns&amp;quot; correspondingly. Window the middle point in the dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f1=2 n1=1 f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every other column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=2 | sfdisfil&lt;br /&gt;
   0:             1            3            5            2            6&lt;br /&gt;
   5:            10            3            9           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every third column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=3 | sfdisfil&lt;br /&gt;
   0:             1            4            2            8            3&lt;br /&gt;
   5:            12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; can use the minimum and maximum&lt;br /&gt;
parameters to select a window. In the following example, we are&lt;br /&gt;
creating a dataset with &amp;lt;b&amp;gt;sfspike&amp;lt;/b&amp;gt; and then windowing a portion of it&lt;br /&gt;
between 1 and 2 seconds in time and sampled at 8 miliseconds.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=1000 n2=10 &amp;gt; spike.rsf         &lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1000        d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10000 elements 40000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow min1=1 max1=2 d1=0.008 &amp;gt; window.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin window.rsf&lt;br /&gt;
window.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/window.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=126         d1=0.008       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        1260 elements 5040 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
By default, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; &amp;quot;squeezes&amp;quot; the hypercube dimensions&lt;br /&gt;
that are equal to one toward the end of the dataset. Here is an&lt;br /&gt;
example of taking a time slice:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=1           d2=0.004       o2=1          label2=&amp;quot;Time&amp;quot; unit2=&amp;quot;s&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can change this behavior by specifying &amp;lt;b&amp;gt;squeeze=n&amp;lt;/b&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 squeeze=n &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1           d1=0.004       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Seismic programs=&lt;br /&gt;
Programs in this category are specific for operations on seismic data. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/seismic/ system/seismic] in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sffkamo==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Computes Azimuth Move-Out (AMO) operator in the f-k log-stretch domain &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffkamo &amp;lt; in.rsf &amp;gt; out.rsf h1= h2= f1= f2= maxe=10.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f1=&#039;&#039;&#039; ||   || 	input azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f2=&#039;&#039;&#039; ||   || 	output azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h1=&#039;&#039;&#039; ||   || 	input offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h2=&#039;&#039;&#039; ||   || 	output offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxe=10.&#039;&#039;&#039; ||   || 	stability constraint&lt;br /&gt;
|}&lt;br /&gt;
Sample workflow from [http://m8r.info/RSF/book/sep/fkamo/paper_html/ SEP-110, 63-70 (2001)], with the addition of a bandpass for the input:&lt;br /&gt;
&lt;br /&gt;
Create input -- a (t,x,y) common-offset cube:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike \&lt;br /&gt;
n1=128 o1=0.4 d1=0.0032 k1=65 label1=t \&lt;br /&gt;
n2=256 o2=-1.536 d2=0.012 k2=129 label2=x \&lt;br /&gt;
n3=128 o3=-1.024 d3=0.016 k3=65 label3=y | \&lt;br /&gt;
sfbandpass flo=5 fhi=60 &amp;gt; spikebps.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply log-stretch FFT:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebps.rsf sfstretch rule=L dens=4 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 &amp;gt; spikefft3.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compute AMO operator for a file of the dimensions of &amp;lt;tt&amp;gt;spikefft3.rsf&amp;lt;/tt&amp;gt;. The only information taken from stdin are the n, o, d parameters:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikefft3.rsf sffkamo h2=2 f2=10 h1=1.8 f1=30 &amp;gt;oper.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the operator by multiplication and fft back to (t, mx, my):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikefft3.rsf sfadd mode=prod oper.rsf |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfstretch rule=L dens=4 inv=y &amp;gt; spikeamo.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prepare for 8-bit greyscale visualization:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sfbyte pclip=100 gainpanel=a &amp;gt; spikebyte.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture from the middle of the impulse response:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebyte.rsf sfgrey3 frame1=65 frame2=129 frame3=65 \&lt;br /&gt;
point1=0.333 title=&#039;AMO saddle, no f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture illustrating the artifacts (i.e. need for f-k filter):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikebyte.rsf sfgrey3 frame1=65 frame2=97 frame3=97 \&lt;br /&gt;
point1=0.333 title=&#039;No f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the f-k filter and (in this case) visualize:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 |\&lt;br /&gt;
sfdipfilter v1=-2.5 v2=-1.5 v3=1.5 v4=2.5 taper=2 pass=0 dim=3 |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfbyte pclip=100 gainpanel=a |\&lt;br /&gt;
sfgrey3 frame1=65 frame2=97 frame3=97 point1=0.333 title=&#039;With f-k filter&#039; |\&lt;br /&gt;
sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheaderattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Integer header attributes. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderattr &amp;lt; head.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Only nonzero values are reported.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; examines the contents of a trace header file,&lt;br /&gt;
typically generated by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;. In the example below, we examine&lt;br /&gt;
trace headers in the output of &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt;, a program from Seismic Unix.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
bash$ sfheaderattr &amp;lt; tfile.rsf&lt;br /&gt;
*******************************************&lt;br /&gt;
71 headers, 32 traces&lt;br /&gt;
key[0]=&amp;quot;tracl&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[1]=&amp;quot;tracr&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[11]=&amp;quot;offset&amp;quot;    min[0]=400          max[31]=400         mean=400&lt;br /&gt;
key[38]=&amp;quot;ns&amp;quot;        min[0]=64           max[31]=64          mean=64&lt;br /&gt;
key[39]=&amp;quot;dt&amp;quot;        min[0]=4000         max[31]=4000        mean=4000&lt;br /&gt;
*******************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For different standard keywords, a minimum, maximum, and mean values&lt;br /&gt;
are reported unless they are identically zero.  This quick inspection&lt;br /&gt;
can help in identifying meaningful keywords set in the data. The input&lt;br /&gt;
data type must be &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfheadermath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations, possibly on header keys. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadermath &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also sfmath. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An addition operation can be performed by sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Describes the output in a mathematical notation.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; is a versatile program for mathematical&lt;br /&gt;
operations on rows of the input file. If the input file is an&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; by &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix, the output will be a &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; by&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix that contains one row made out of mathematical&lt;br /&gt;
operations on the other rows. &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; can identify a row&lt;br /&gt;
by number or by a standard SEGY keyword. The latter is useful for&lt;br /&gt;
processing headers extracted from SEGY or SU files.&lt;br /&gt;
Here is an example. First, we create an SU file with &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt; and convert it to RSF using &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The trace header information is saved in &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt;. It&lt;br /&gt;
contains 71 headers for 32 traces in integer format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin tfile.rsf&lt;br /&gt;
tfile.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/tfile.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=int form=native&lt;br /&gt;
    n1=71          d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        2272 elements 9088 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we will convert &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt; to a floating-point format&lt;br /&gt;
and run &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; to create a new header.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; tfile.rsf sfdd type=float | \&lt;br /&gt;
sfheadermath myheader=1 output=&amp;quot;sqrt(myheader+(2+10*offset^2))&amp;quot; &amp;gt; new.rsf&lt;br /&gt;
bash$ sfin new.rsf&lt;br /&gt;
new.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/new.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1           d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        32 elements 128 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We defined &amp;quot;myheader&amp;quot; as being the row number 1 in the input (note&lt;br /&gt;
that numbering starts with 0) and combined it with &amp;quot;offset&amp;quot;, which&lt;br /&gt;
is a standard SEGY keyword that denotes row number 11 (see the output&lt;br /&gt;
of &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; above.) A variety of mathematical expressions&lt;br /&gt;
can be defined in the &amp;lt;tt&amp;gt;output=&amp;lt;/tt&amp;gt; string. The expression&lt;br /&gt;
processing engine is shared with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfsegyheader==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Make a trace header file for segywrite.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyheader &amp;lt; in.rsf &amp;gt; out.rsf n1= d1=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;   Use the output for tfile= argument in segywrite.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=&#039;&#039;&#039; ||   ||      trace sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=&#039;&#039;&#039; ||   ||      number of samples in a trace&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==sfsegyread==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a SEG-Y or SU dataset to RSF.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyread mask=msk.rsf &amp;gt; out.rsf tfile=hdr.rsf verb=n su= suxdr=n endian=y format=segyformat (bhead) ns=segyns (bhead) tape= read= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Data headers and trace headers are separated from the data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;suread&amp;quot; is equivalent to &amp;quot;segyread su=y&amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;SEGY key names:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracl: trace sequence number within line 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracr: trace sequence number within reel 4&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;fldr:     field record number 8 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracf:    trace number within field record 12 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ep:       energy source point number 16 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdp:      CDP ensemble number 20 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpt:     trace number within CDP ensemble 24 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trid:     trace identification code:&amp;lt;br&amp;gt;1 = seismic data&amp;lt;br&amp;gt;2 = dead&amp;lt;br&amp;gt;3 = dummy&amp;lt;br&amp;gt;4 = time break&amp;lt;br&amp;gt;5 = uphole&amp;lt;br&amp;gt;6 = sweep&amp;lt;br&amp;gt;7 = timing&amp;lt;br&amp;gt;8 = water break&amp;lt;br&amp;gt;9---, N = optional use (N = 32,767) 28 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nvs:      number of vertically summed traces 30 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nhs:      number of horizontally summed traces 32 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;duse:     data use:&amp;lt;br&amp;gt;1 = production&amp;lt;br&amp;gt;2 = test 34&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;offset:   distance from source point to receiver&amp;lt;br&amp;gt;group (negative if opposite to direction&amp;lt;br&amp;gt;in which the line was shot) 36 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gelev:    receiver group elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 40 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;selev:    source elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 44 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdepth:   source depth (positive) 48 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gdel:     datum elevation at receiver group 52 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdel:     datum elevation at source 56 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swdep:    water depth at source 60 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gwdep:    water depth at receiver group 64 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalel:   scale factor for previous 7 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 68 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalco:   scale factor for next 4 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 70 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sx:       X source coordinate 72 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sy:       Y source coordinate 76 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gx:       X group coordinate 80 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gy:       Y group coordinate 84 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;counit:   coordinate units code:&amp;lt;br&amp;gt;for previous four entries&amp;lt;br&amp;gt;1 = length (meters or feet)&amp;lt;br&amp;gt;2 = seconds of arc (in this case, the&amp;lt;br&amp;gt;X values are unsigned longitude and the Y values&amp;lt;br&amp;gt;are latitude, a positive value designates&amp;lt;br&amp;gt;the number of seconds east of Greenwich&amp;lt;br&amp;gt;or north of the equator 88 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;wevel:     weathering velocity 90 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swevel:    subweathering velocity 92 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sut:       uphole time at source 94 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gut:       uphole time at receiver group 96 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sstat:     source static correction 98 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gstat:     group static correction 100 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tstat:     total static applied 102 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;laga:      lag time A, time in ms between end of 240-&amp;lt;br&amp;gt;byte trace identification header and time&amp;lt;br&amp;gt;break, positive if time break occurs after&amp;lt;br&amp;gt;end of header, time break is defined as&amp;lt;br&amp;gt;the initiation pulse which maybe recorded&amp;lt;br&amp;gt;on an auxiliary trace or as otherwise&amp;lt;br&amp;gt;specified by the recording system 104 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lagb:      lag time B, time in ms between the time&amp;lt;br&amp;gt;break and the initiation time of the energy source,&amp;lt;br&amp;gt;may be positive or negative 106 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;delrt:     delay recording time, time in ms between&amp;lt;br&amp;gt;initiation time of energy source and time&amp;lt;br&amp;gt;when recording of data samples begins&amp;lt;br&amp;gt;(for deep water work if recording does not&amp;lt;br&amp;gt;start at zero time) 108 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;muts:      mute time--start 110 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;mute:      mute time--end 112 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ns:        number of samples in this trace 114 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;dt:        sample interval, in micro-seconds 116 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gain:      gain type of field instruments code:&amp;lt;br&amp;gt;1 = fixed&amp;lt;br&amp;gt;2 = binary&amp;lt;br&amp;gt;3 = floating point&amp;lt;br&amp;gt;4 ---- N = optional use 118 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igc:       instrument gain constant 120 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igi:       instrument early or initial gain 122 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;corr:      correlated:&amp;lt;br&amp;gt;1 = no&amp;lt;br&amp;gt;2 = yes 124&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfs:       sweep frequency at start 126 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfe:       sweep frequency at end 128 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;slen:      sweep length in ms 130 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;styp:      sweep type code:&amp;lt;br&amp;gt;1 = linear&amp;lt;br&amp;gt;2 = cos-squared&amp;lt;br&amp;gt;3 = other 132&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stas:      sweep trace length at start in ms 134 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stae:      sweep trace length at end in ms 136 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tatyp:     taper type: 1=linear, 2=cos^2, 3=other 138 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afilf:     alias filter frequency if used 140 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afils:     alias filter slope 142 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofilf:    notch filter frequency if used 144 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofils:    notch filter slope 146 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcf:       low cut frequency if used 148 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcf:       high cut frequncy if used 150 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcs:       low cut slope 152 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcs:       high cut slope 154 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;year:      year data recorded 156 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;day:       day of year 158 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hour:      hour of day (24 hour clock) 160 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;minute:    minute of hour 162 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sec:       second of minute 164 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;timbas:    time basis code:&amp;lt;br&amp;gt;1 = local&amp;lt;br&amp;gt;2 = GMT&amp;lt;br&amp;gt;3 = other 166&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trwf:      trace weighting factor, defined as 1/2^N&amp;lt;br&amp;gt;volts for the least sigificant bit 168 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnors:    geophone group number of roll switch&amp;lt;br&amp;gt;position one 170&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnofr:    geophone group number of trace one within&amp;lt;br&amp;gt;original field record 172&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnlof:    geophone group number of last trace within&amp;lt;br&amp;gt;original field record 174&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gaps:      gap size (total number of groups dropped) 176 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;otrav:     overtravel taper code: &amp;lt;br&amp;gt;1 = down (or behind)&amp;lt;br&amp;gt;2 = up (or ahead) 178&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpx:   X coordinate of CDP 180&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpy:   Y coordinate of CDP 184&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;iline:  in-line number 188 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;xline:  cross-line number 192&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shnum:  shotpoint number 196&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shsca:  shotpoint scalar 200&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tval:   trace value meas. 202&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst4: transduction const 204&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst2: transduction const 208&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tunits:  transduction units 210&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;device:  device identifier 212&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tscalar: time scalar 214&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stype:   source type 216&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sendir:  source energy dir. 218&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;unknown: unknown 222&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas4:  source measurement 224&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas2:  source measurement 228&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeasu:  source measurement unit 230 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass1:  unassigned 232&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass2:  unassigned 236&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   || 	output binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=y&#039;&#039;&#039; ||  [y/n] || 	Whether to automatically estimate endianness or not&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;format=segyformat (bhead)&#039;&#039;&#039; ||  [1,2,3,5] || 	Data format. The default is taken from binary header.&lt;br /&gt;
:1 is IBM floating point&lt;br /&gt;
:2 is 4-byte integer&lt;br /&gt;
:3 is 2-byte integer&lt;br /&gt;
:5 is IEEE floating point&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   || 	output text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	optional header mask for reading only selected traces (auxiliary input file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ns=segyns (bhead)&#039;&#039;&#039; ||   || 	Number of samples. The default is taken from binary header&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;read=&#039;&#039;&#039; ||   || 	what to read: h - header, d - data, b - both (default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=&#039;&#039;&#039; ||  [y/n] || 	y if input is SU, n if input is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;suxdr=n&#039;&#039;&#039; ||  [y/n] || 	y, SU has XDR support&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   || 	input data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tfile=&#039;&#039;&#039; ||   || 	output trace header file (auxiliary output file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The SEG Y format is an [http://en.wikipedia.org/wiki/Open_standard open standard] for the exchange of geophysical data. It is controlled by the non-profit [http://www.seg.org/SEGportalWEBproject/portals/SEG_Online.portal?_nfpb=true&amp;amp;_pageLabel=pg_gen_content&amp;amp;Doc_Url=prod/SEG-Publications/Pub-Yearbook/committees.htm SEG Technical Standards Committee]. There are two versions of this standard: [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev0.pdf rev0] (1975)&amp;lt;ref&amp;gt;Barry, K.M., Cavers, D.A., and Kneale, C.W. 1975. Recommended standards for digital tape formats. &#039;&#039;Geophysics&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, no. 02, 344–352.&amp;lt;/ref&amp;gt; and [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf rev1] (2002)&amp;lt;ref&amp;gt;Norris, M.W., Faichney, A.K., &#039;&#039;Eds&#039;&#039;. 2001. SEG Y rev1 Data Exchange format. Society of Exploration Geophysicists, Tulsa, OK, 45 pp.&amp;lt;/ref&amp;gt;. The implementation in &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; is a mixture of rev0 (i.e. no checks for Extended Textual Headers) and rev1 ([http://en.wikipedia.org/wiki/IEEE_floating-point_standard IEEE floating point format] allowed for trace data samples).&lt;br /&gt;
&lt;br /&gt;
A SEG-Y file as understood by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; contains a &amp;quot;Reel Identification Header&amp;quot; (3200 bytes in EBCDIC followed by 400 bytes in a binary encoding), followed by a number of &amp;quot;Trace Blocks&amp;quot;. Each &amp;quot;Trace Block&amp;quot; contains a 240-byte &amp;quot;Trace Header&amp;quot; (binary) followed by &amp;quot;Trace Data&amp;quot; -- a sequence of &amp;lt;tt&amp;gt;ns&amp;lt;/tt&amp;gt; samples. Binary values in both reel headers and trace headers are two&#039;s complement integers, either two bytes or four bytes long. There are no floating-point values defined in the headers. Trace Data samples can have various encodings, either floating point or integer, described further down, but they are all big-endian. To convert from SEG-Y to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will strip the tape reel EBCDIC header and convert it to ASCII, will extract the reel binary header without changing it, and will put the trace headers into one RSF file, and the traces themselves on another.&lt;br /&gt;
&lt;br /&gt;
===SEG-Y Trace Headers===&lt;br /&gt;
In the SEG-Y standard, only the first 180 bytes of the 240-byte trace header are defined; bytes 181-240 are reserved for non-standard header information, and these locations are increasingly used in modern SEG-Y files and its variants. The standard provides for a total of 71 4-byte and 2-byte predefined header words. These 71 standard words have defined lengths and byte offsets, and only these words and byte locations are read using &amp;lt;tt&amp;gt;segyread&amp;lt;/tt&amp;gt; and output to the RSF header file with the &amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; option. The user may remap these predefined keywords to a different byte offsets.&lt;br /&gt;
&lt;br /&gt;
===SU File Format===&lt;br /&gt;
An [http://www.cwp.mines.edu/sututor/node22.html SU file] is nothing more than a SEG-Y file without the reel headers, and with the Trace Data samples in the native encoding of the CPU the file was created on (Attention -- limited portability!). So, to convert from SU to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will just separate headers and traces into two RSF files. &lt;br /&gt;
&lt;br /&gt;
===SEG-Y specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; specifies the name of the file in which the EBCDIC reel header will be put after conversion to ASCII. If you are certain there is no useful information in it, &amp;lt;tt&amp;gt;hfile=/dev/null&amp;lt;/tt&amp;gt; works just fine. If you do not specify anything for this parameter you will get an ASCII file named &amp;lt;tt&amp;gt;header&amp;lt;/tt&amp;gt; in the current directory. If you want to quickly preview this header before running &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;, use&amp;lt;pre&amp;gt;dd if=input.segy count=40 bs=80 cbs=80 conv=unblock,ascii&amp;lt;/pre&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;bfile=&amp;lt;/tt&amp;gt; specifies name of the file in which the binary reel header (the 400-bytes thing following the 3600-bytes EBCDIC) will be put without any conversion. The default name is &amp;quot;binary&amp;quot;. Unless you have software that knows how to read exactly this special type of file, it will be completely useless, so do &amp;lt;tt&amp;gt;bfile=/dev/null&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;format=&amp;lt;/tt&amp;gt; specifies the format in which the trace data samples are in the SEG-Y input file. This is read from the binary reel header of the SEG-Y file. Valid values are 1(IBM floating point), 2 (4-byte integer), 3 (2-byte integer) and 5 (IEEE floating point). If the input file is SU, the format will be assumed to be the native &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;tt&amp;gt;keyname=&amp;lt;/tt&amp;gt; specifies the byte offset to remap a header using the trace header key names shown above. For example, if the CDP locations have been placed in bytes 181-184 instead of the standard 21-24, &amp;lt;tt&amp;gt;cdp=180&amp;lt;/tt&amp;gt; will remap the trace header to that location. &lt;br /&gt;
&lt;br /&gt;
===SU-specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;suxdr=&amp;lt;/tt&amp;gt; specifies whether the input file was created with a SU package with XDR support enabled. If you have access to the source code of your SU install (try &amp;lt;tt&amp;gt;$CWPROOT/src&amp;lt;/tt&amp;gt;), type: &amp;lt;tt&amp;gt;grep &#039;XDRFLAG =&#039; $CWPROOT/src/Makefile.config&amp;lt;/tt&amp;gt; and look at the last uncommented entry. If no value is given for &amp;lt;tt&amp;gt;XDRFLAG&amp;lt;/tt&amp;gt;, the package was not compiled with XDR support.&lt;br /&gt;
===Common parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;su=&amp;lt;/tt&amp;gt; specifies if the input file is SU or SEG-Y. Default is &amp;lt;tt&amp;gt;su=n&amp;lt;/tt&amp;gt; (SEG-Y file).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; specifies the input data. Stdin could not be used because &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; has to work with tapes, and needs to fseek back and forth through the input file. Thankfully, output is on stdout.&lt;br /&gt;
*&amp;lt;tt&amp;gt;read=&amp;lt;/tt&amp;gt; specifies what parts of the &amp;quot;Trace Blocks&amp;quot; will be read. It can be &amp;lt;tt&amp;gt;read=t&amp;lt;/tt&amp;gt; (only trace data is read), &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; (only trace headers are read) or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt; (both are read).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tfile=&amp;lt;/tt&amp;gt; gives the name of the RSF file to which trace headers are written. Obviously, it should be only specified with &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;mask=&amp;lt;/tt&amp;gt; is an optional parameter specifying the name of a mask that says which traces will be read. The mask is a 1-D RSF file with integers. The number of samples in the mask is the same as the number of traces in the unmasked SEG-Y. In places corresponding to unwanted traces there should be zeros in the mask.&lt;br /&gt;
*&amp;lt;tt&amp;gt;ns=&amp;lt;/tt&amp;gt; specifies the number of samples in a trace. For SEG-Y files, the default is taken from the binary reel header, and for SU files, from the header of the first trace. This parameter is however critical enough that a command line override was given for it.&lt;br /&gt;
*&amp;lt;tt&amp;gt;verbose=&amp;lt;/tt&amp;gt; is the verbosity flag. Can be &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;endian=&amp;lt;/tt&amp;gt; is a y/n flag (default y), specifying whether to automatically estimate or not if samples in the Trace Data blocks are big-endian or little-endian. Try it if you are in trouble and do not know what else to do, otherwise let the automatic estimation do its job.&lt;br /&gt;
&lt;br /&gt;
==sfsegywrite==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert an RSF dataset to SEGY or SU.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegywrite &amp;lt; in.rsf tfile=hdr.rsf verb=false su=false endian=sf_endian() tape= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Merges trace headers with data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   ||   input binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=sf_endian()&#039;&#039;&#039; ||  [y/n] ||  big/little endian flag. The default is estimated automatically&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   ||   input text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=n&#039;&#039;&#039; ||  [y/n] ||        y if output is SU, n if output is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] ||   Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
Please see &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; for a complete description of parameter meanings and background issues. Parameters &amp;lt;tt&amp;gt;bfile&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;hfile&amp;lt;/tt&amp;gt; should only be given values when the desired file is SEG-Y (default). The output file is specified by the &amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; tag.&lt;br /&gt;
=Generic programs=&lt;br /&gt;
Programs in this category are general signal and image processing programs. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/generic/ system/generic] in the Madagascar distribution.&lt;br /&gt;
==sfnoise==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add random noise to the data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfnoise &amp;lt; in.rsf &amp;gt; out.rsf seed=time(NULL) type=y var= range= mean=0 rep=n&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;mean=0&#039;&#039;&#039; ||   || 	noise mean&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;range=&#039;&#039;&#039; ||   || 	noise range (default=1)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rep=n&#039;&#039;&#039; ||  [y/n] || 	if y, replace data with noise&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;seed=time(NULL)&#039;&#039;&#039; ||   || 	random seed&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;type=y&#039;&#039;&#039; ||  [y/n] || 	noise distribution, y: normal, n: uniform&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;var=&#039;&#039;&#039; ||   || 	noise variance&lt;br /&gt;
|}&lt;br /&gt;
See the [http://www.ahay.org/rsflog/index.php?/archives/262-Program-of-the-month-sfnoise.html Program of the Month] blog entry.&lt;br /&gt;
&lt;br /&gt;
=Plotting programs (stable)=&lt;br /&gt;
The source files for these programs can be found under&lt;br /&gt;
[http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/plot/main/ plot/main]&lt;br /&gt;
in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sfbox==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Draw a balloon-style label.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfbox lab_color=VP_WHITE lab_fat=0 pscale=1. pointer=y reverse=n lat=0. long=90. angle=0. x0=0. y0=0. scale0=1. xt=2. yt=0. x_oval=0. y_oval=0. boxit=y length= scalet= size=.25 label= &amp;gt; out.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;angle=0.&#039;&#039;&#039; ||   || 	longitude of floating label in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;boxit=y&#039;&#039;&#039; ||  [y/n] || 	if y, create a box around text&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_color=VP_WHITE&#039;&#039;&#039; ||   || 	label color&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_fat=0&#039;&#039;&#039; ||   || 	label fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	text for label&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;lat=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;length=&#039;&#039;&#039; ||   || 	normalization for xt and yt&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;long=90.&#039;&#039;&#039; ||   || 	latitude and longitude of viewpoint in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;pointer=y&#039;&#039;&#039; ||  [y/n] || 	if y, create arrow pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pscale=1.&#039;&#039;&#039; ||   || 	scale factor for width of pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;reverse=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scale0=1.&#039;&#039;&#039; ||   || 	scale factor for x0 and y0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scalet=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;size=.25&#039;&#039;&#039; ||   || 	text height in inches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x0=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x_oval=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xt=2.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y0=0.&#039;&#039;&#039; ||   || 	position of the pointer tip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y_oval=0.&#039;&#039;&#039; ||   || 	size of the oval around pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yt=0.&#039;&#039;&#039; ||   || 	relative position of text&lt;br /&gt;
|}&lt;br /&gt;
==sfcontour==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Contour plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcontour &amp;lt; in.rsf c= min1=o1 min2=o2 max1=o1+(n1-1)*d1 max2=o2+(n2-1)*d2 nc=50 dc= c0= transp=y minval= maxval= allpos=y barlabel= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=y&#039;&#039;&#039; ||  [y/n] || 	contour positive values only&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;barlabel=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;c=&#039;&#039;&#039; ||   || 	 [nc]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;c0=&#039;&#039;&#039; ||   || 	first contour&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dc=&#039;&#039;&#039; ||   || 	contour increment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max1=o1+(n1-1)*d1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max2=o2+(n2-1)*d2&#039;&#039;&#039; ||   || 	data window to plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min1=o1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min2=o2&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nc=50&#039;&#039;&#039; ||   || 	number of contours&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfdots==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot signal with lollipops.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdots &amp;lt; in.rsf labels= dots=(n1 &amp;lt;= 130)? 1: 0 seemean=(bool) (n2 &amp;lt;= 30) strings=(bool) (n1 &amp;lt;= 400) connect=1 corners= silk=n gaineach=y labelsz=8 yreverse=n constsep=n seedead=n transp=n xxscale=1. yyscale=1. clip=-1. overlap=0.9 screenratio=VP_SCREEN_RATIO screenht=VP_STANDARD_HEIGHT screenwd=screenhigh / screenratio radius=dd1/3 label1= unit1= title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=-1.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;connect=1&#039;&#039;&#039; ||   || 	connection type: 1 - diagonal, 2 - bar, 4 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;constsep=n&#039;&#039;&#039; ||  [y/n] || 	if y, use constant trace separation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;corners=&#039;&#039;&#039; ||   || 	number of polygon corners (default is 6)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dots=(n1 &amp;lt;= 130)? 1: 0&#039;&#039;&#039; ||   || 	type of dots: 1 - baloon, 0 - no dots, 2 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;gaineach=y&#039;&#039;&#039; ||  [y/n] || 	if y, gain each trace independently&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;strings&#039;&#039; || &#039;&#039;&#039;labels=&#039;&#039;&#039; ||   || 	trace labels  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;labelsz=8&#039;&#039;&#039; ||   || 	label size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;overlap=0.9&#039;&#039;&#039; ||   || 	trace overlap&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;radius=dd1/3&#039;&#039;&#039; ||   || 	dot radius&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenht=VP_STANDARD_HEIGHT&#039;&#039;&#039; ||   || 	screen height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenratio=VP_SCREEN_RATIO&#039;&#039;&#039; ||   || 	screen aspect ratio&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenwd=screenhigh / screenratio&#039;&#039;&#039; ||   || 	screen width&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seedead=n&#039;&#039;&#039; ||  [y/n] || 	if y, show zero traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=(bool) (n2 &amp;lt;= 30)&#039;&#039;&#039; ||  [y/n] || 	if y, draw axis lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;silk=n&#039;&#039;&#039; ||  [y/n] || 	if y, silky plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;strings=(bool) (n1 &amp;lt;= 400)&#039;&#039;&#039; ||  [y/n] || 	if y, draw strings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xxscale=1.&#039;&#039;&#039; ||   || 	x scaling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse y axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yyscale=1.&#039;&#039;&#039; ||   || 	y scaling&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot for surfaces.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph3 &amp;lt; in.rsf orient=1 min= max= point1=0.5 point2=0.5 frame1=0.5*(min+max) frame2=n1-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;frame1=0.5*(min+max)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n1-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=&#039;&#039;&#039; ||   || 	maximum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=&#039;&#039;&#039; ||   || 	minimum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;orient=1&#039;&#039;&#039; ||   || 	function orientation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Graph plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph &amp;lt; in.rsf symbolsz= pclip=100. transp=n symbol= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;symbol=&#039;&#039;&#039; ||   || 	if set, plot with symbols instead of lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;symbolsz=&#039;&#039;&#039; ||   || 	symbol size (default is 2)  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfgrey3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey3 &amp;lt; in.rsf point1=0.5 point2=0.5 frame1=0 frame2=n2-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y scalebar=n minval= maxval= barreverse=n nreserve=8 bar= color= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Requires an &amp;quot;unsigned char&amp;quot; input (the output of sfbyte).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame1=0&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n2-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || 	if y, draw scalebar&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
for sfgrey and sfgrey3. Examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfgrey==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate raster plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey &amp;lt; in.rsf &amp;gt; out.rsf bar=bar.rsf transp=y yreverse=y xreverse=n gpow= phalf= clip= pclip= gainstep=0.5+n1/256. allpos=n bias=0. polarity=n verb=n scalebar=n minval= maxval= barreverse=n wantframenum=(bool) (n3 &amp;gt; 1) nreserve=8 gainpanel= bar= color= &amp;gt; (plot.vpl | char.rsf)&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Can input char values.&amp;lt;br&amp;gt;If called &amp;quot;byte&amp;quot;, outputs char values.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=n&#039;&#039;&#039; ||  [y/n] || 	if y, assume positive data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;gainpanel=&#039;&#039;&#039; ||   || 	gain reference: &#039;a&#039; for all, &#039;e&#039; for each, or number&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+n1/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=&#039;&#039;&#039; ||   || 	data clip percentile (default is 99)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;phalf=&#039;&#039;&#039; ||   || 	percentage for estimating gpow&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;polarity=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse polarity (white is high by default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the display axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;wantframenum=(bool) (n3 &amp;gt; 1)&#039;&#039;&#039; ||  [y/n] || 	if y, display third axis position in the corner&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=y&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
and examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfplas==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Assembler - convert ascii to vplot. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplas&lt;br /&gt;
|}&lt;br /&gt;
==sfpldb==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Debugger - convert vplot to ascii. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpldb&lt;br /&gt;
|}&lt;br /&gt;
==sfplotrays==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot rays.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplotrays frame=frame.rsf nt=n1*n2 jr=1 frame= &amp;lt; rays.rsf &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;frame=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jr=1&#039;&#039;&#039; ||   || 	skip rays&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nt=n1*n2&#039;&#039;&#039; ||   || 	maximum ray length&lt;br /&gt;
|}&lt;br /&gt;
==sfthplot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Hidden-line surface plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfthplot &amp;lt; in.rsf uflag=y dflag=y alpha=45. titlsz=9 axissz=6 plotfat=0 titlefat=2 axisfat=2 plotcolup=VP_YELLOW plotcoldn=VP_RED axis=y axis1=y axis2=y axis3=y clip=0. pclip=100. gainstep=0.5+nx/256. bias=0. dclip=1. norm=y xc=1.5 zc=3 ratio=5. zmax= zmin= sz=6. label#= unit#= tpow=0 epow=0 gpow=1 title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;alpha=45.&#039;&#039;&#039; ||   || 	apparent angle in degrees, |alpha| &amp;lt; 89&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis1=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis2=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis3=y&#039;&#039;&#039; ||  [y/n] || 	plot axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axisfat=2&#039;&#039;&#039; ||   || 	axes fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axissz=6&#039;&#039;&#039; ||   || 	axes size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dclip=1.&#039;&#039;&#039; ||   || 	change the clip: clip *= dclip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;dflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot down side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;epow=0&#039;&#039;&#039; ||   || 	exponential gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+nx/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=1&#039;&#039;&#039; ||   || 	power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	normalize by the clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	data clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcoldn=VP_RED&#039;&#039;&#039; ||   || 	color of the lower side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcolup=VP_YELLOW&#039;&#039;&#039; ||   || 	color of the upper side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotfat=0&#039;&#039;&#039; ||   || 	line fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ratio=5.&#039;&#039;&#039; ||   || 	plot adjustment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;sz=6.&#039;&#039;&#039; ||   || 	vertical scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlefat=2&#039;&#039;&#039; ||   || 	title fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlsz=9&#039;&#039;&#039; ||   || 	title size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tpow=0&#039;&#039;&#039; ||   || 	time power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;uflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot upper side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xc=1.5&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zc=3&#039;&#039;&#039; ||   || 	lower left corner of the plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmax=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmin=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
==sfwiggle==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot data with wiggly traces. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwiggle &amp;lt; in.rsf xpos=xpos.rsf xmax= xmin= poly=n fatp=1 xmask=1 ymask=1 pclip=98. zplot=0.75 clip=0. seemean=n verb=n transp=n yreverse=n xreverse=n xpos= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip (estimated from pclip by default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;fatp=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=98.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;poly=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=n&#039;&#039;&#039; ||  [y/n] || 	if y, plot mean lines of traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;xmask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmax=&#039;&#039;&#039; ||   || 	maximum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmin=&#039;&#039;&#039; ||   || 	minimum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;xpos=&#039;&#039;&#039; ||   || 	optional header file with trace positions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ymask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zplot=0.75&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
=Plotting programs (development)=&lt;br /&gt;
==sfplsurf==&lt;br /&gt;
&amp;lt;tt&amp;gt;sfplsurf&amp;lt;/tt&amp;gt; utilizes PLplot&#039;s surface rendering capabilities. Output is dumped to stdout in VPLOT format, so it can easily be used in the same way as &amp;lt;tt&amp;gt;sfgrey&amp;lt;/tt&amp;gt; or other plotting programs. It also supports animation, if n3 &amp;gt; 1 in the input file. A SConstruct usage example can be found below. A [http://reproducibility.org/wikilocal/movies/sfplsurf_membrane.mpg movie of the output] is available as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# x &amp;amp; y dimensions&lt;br /&gt;
o1=-2&lt;br /&gt;
o2=-2&lt;br /&gt;
n1=41&lt;br /&gt;
n2=41&lt;br /&gt;
d1=0.1&lt;br /&gt;
d2=0.1&lt;br /&gt;
# z dimension&lt;br /&gt;
o3=-1&lt;br /&gt;
n3=21&lt;br /&gt;
d3=0.1&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;membrane&#039;,None,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    math o1=%g o2=%g n1=%d n2=%d d1=%g d2=%g&lt;br /&gt;
          o3=%g n3=%d d3=%g&lt;br /&gt;
          output=&amp;quot;x3*cos(x1*x1+x2*x2)*exp(-0.1*(x1*x1+x2*x2))&amp;quot;&lt;br /&gt;
    &#039;&#039;&#039; % (o1,o2,n1,n2,d1,d2,o3,n3,d3))&lt;br /&gt;
&lt;br /&gt;
Result(&#039;membrane&#039;,&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      plsurf title=&amp;quot;Membrane&amp;quot; mesh=n color=j&lt;br /&gt;
              minval=%g maxval=%g&lt;br /&gt;
      &#039;&#039;&#039; % (o3,o3 + d3*(n3-1)))&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=system/generic programs=&lt;br /&gt;
==sfremap1==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 1-D ENO interpolation. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfremap1 &amp;lt; in.rsf &amp;gt; out.rsf pattern=pattern.rsf n1=n1 d1=d1 o1=o1 order=3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=d1&#039;&#039;&#039; ||   || 	Output sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=n1&#039;&#039;&#039; ||   || 	Number of output samples&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=o1&#039;&#039;&#039; ||   || 	Output origin&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;order=3&#039;&#039;&#039; ||   || 	Interpolation order&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;pattern=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
To give an example of usage, we will create an input for &amp;lt;tt&amp;gt;sfremap1&amp;lt;/tt&amp;gt; with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=11 n2=11 d1=1 d2=1 o1=-5 o2=-5 output=&amp;quot;x1*x1+x2*x2&amp;quot; &amp;gt; inp2remap1.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Let us interpolate the data across both dimensions, then display it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt; inp2remap1.rsf sfremap1 n1=1001 d1=0.01 | sftransp | \&lt;br /&gt;
sfremap1 n1=1001 d1=0.01 | sftransp | sfgrey allpos=y | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The comparison with the uninterpolated data ( &amp;lt;tt&amp;gt;&amp;amp;lt; inp2remap1.rsf sfgrey allpos=y | sfpen&amp;lt;/tt&amp;gt; ) is quite telling.&lt;br /&gt;
&lt;br /&gt;
=system/seismic programs=&lt;br /&gt;
==sfstretch==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stretch of the time axis. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstretch &amp;lt; in.rsf &amp;gt; out.rsf datum=dat.rsf inv=n dens=1 v0= half=y delay= tdelay= hdelay= nout=dens*n1 extend=4 mute=0 maxstr=0 rule=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;datum=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;delay=&#039;&#039;&#039; ||   || 	time delay for rule=lmo&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dens=1&#039;&#039;&#039; ||   || 	axis stretching factor&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;extend=4&#039;&#039;&#039; ||   || 	trace extension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;half=y&#039;&#039;&#039; ||  [y/n] || 	if y, the second axis is half-offset instead of full offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;hdelay=&#039;&#039;&#039; ||   || 	offset delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;inv=n&#039;&#039;&#039; ||  [y/n] || 	if y, do inverse stretching&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxstr=0&#039;&#039;&#039; ||   || 	maximum stretch&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;mute=0&#039;&#039;&#039; ||   || 	tapering size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nout=dens*n1&#039;&#039;&#039; ||   || 	output axis length (if inv=n)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;rule=&#039;&#039;&#039; ||   || 	Stretch rule:&lt;br /&gt;
:n - normal moveout (nmostretch), default&lt;br /&gt;
:l - linear moveout (lmostretch)&lt;br /&gt;
:L - logarithmic stretch (logstretch)&lt;br /&gt;
:2 - t^2 stretch (t2stretch)&lt;br /&gt;
:c - t^2 chebyshev stretch (t2chebstretch)&lt;br /&gt;
:r - radial moveout (radstretch)&lt;br /&gt;
:d - datuming (datstretch)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;tdelay=&#039;&#039;&#039; ||   || 	time delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;v0=&#039;&#039;&#039; ||   || 	moveout velocity&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstretch rule=d&amp;lt;/tt&amp;gt; (aka &amp;lt;tt&amp;gt;sfdatstretch&amp;lt;/tt&amp;gt;) can be used to apply statics. Here is a synthetic example, courtesy of Alessandro Frigeri:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# generate a dataset with &#039;flat&#039; signals&lt;br /&gt;
sfmath n1=200 n2=100 output=&amp;quot;sin(0.5*x1)&amp;quot; type=float &amp;gt; scan.rsf&lt;br /&gt;
&lt;br /&gt;
# generate a sinusoidal elevation correction&lt;br /&gt;
sfmath n1=100 output=&amp;quot;3*sin(x1)&amp;quot; type=float &amp;gt; statics.rsf&lt;br /&gt;
&lt;br /&gt;
# apply statics, producing a &#039;wavy&#039; output.&lt;br /&gt;
sfstretch &amp;lt; scan.rsf &amp;gt; out.rsf datum=statics.rsf rule=d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/fomels programs=&lt;br /&gt;
==sfpick==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Automatic picking  from semblance-like panels. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpick &amp;lt; scn.rsf &amp;gt; pik.rsf vel0=o2 niter=100 an=1. gate=3 smooth=y rect#=(1,1,...) rect1=1 rect2=1 ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | rectN defines the size of the smoothing stencil in N-th dimension.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Theory in Appendix B of:&amp;lt;br&amp;gt;S. Fomel, 2009, &amp;lt;br&amp;gt;Velocity analysis using AB semblance: Geophysical Prospecting, v. 57, 311-321.&amp;lt;br&amp;gt;Reproducible version in RSFSRC/book/jsg/avo &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;an=1.&#039;&#039;&#039; ||   || 	axes anisotropy&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gate=3&#039;&#039;&#039; ||   || 	picking gate&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=100&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rect#=(1,1,...)&#039;&#039;&#039; ||   || 	smoothing radius on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;smooth=y&#039;&#039;&#039; ||  [y/n] || 	if apply smoothing&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vel0=o2&#039;&#039;&#039; ||   || 	surface velocity&lt;br /&gt;
|}&lt;br /&gt;
Short description of the algorithm:&lt;br /&gt;
# Start from the top (first time slice), pick an initial (source) point, evaluate all other points with the direct traveltime.&lt;br /&gt;
# At each grid point at the next level, find the traveltime to points at the previous level, add the traveltimes from the previous level, and select minimum. The search radius is limited by the aperture (gate= parameter in sfpick).&lt;br /&gt;
# Repeat step 2 until reaching the bottom.&lt;br /&gt;
# Pick the minimum traveltime at the bottom and track the ray back to the source by following the traveltime gradient direction.&lt;br /&gt;
# Postprocessing (smooth= parameter in sfpick): smooth the picked ray path using shaping regularization.&lt;br /&gt;
&lt;br /&gt;
The algorithm was discovered and rediscovered by many people. The best reference is probably &#039;&#039;V. Meshbey, E. Ragoza, D. Kosloff, U. Egozi, and D. Wexler, 2002, Three-dimensional Travel-time Calculation Based on Fermat&#039;s Principle: Pure and Applied Geophysics, v. 159, 1563-1582.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=user/ivlad programs=&lt;br /&gt;
==sfprep4plot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Resamples a 2-D dataset to the desired picture resolution, with antialias&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfprep4plot inp= out= verb=n h=none w=none unit= ppi= prar=y&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Only one of the h and w parameters needs to be specified.&amp;lt;br&amp;gt;If prar=n, no action will be taken on axis for which h/w was not specified&amp;lt;br&amp;gt;If prar=y and only one par (h or w) is specified, the picture will scale&amp;lt;br&amp;gt;along both axes until it is of the specified dimension.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;h=none&#039;&#039;&#039; ||   || 	output height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;inp=&#039;&#039;&#039; ||   || 	input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;out=&#039;&#039;&#039; ||   || 	output file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ppi=&#039;&#039;&#039; ||   || 	output resolution (px/in). Necessary when unit!=px&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;prar=y&#039;&#039;&#039; ||  [y/n] || 	if y, PReserve Aspect Ratio of input&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	unit of h and w. Can be: px(default), mm, cm, in&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	if y, print system commands, outputs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;w=none&#039;&#039;&#039; ||   || 	output width&lt;br /&gt;
|}&lt;br /&gt;
For a figure that does not need the aspect ratio preserved,&lt;br /&gt;
and needs to fill a 1280x1024 projector display:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=1280 h=1024 prar=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a print figure that has to fit in a 6x8in box&lt;br /&gt;
at a resolution of 250 dpi, preserving the aspect ratio:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=6 h=8 unit=in ppi=250&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A comparison of images before and after the application of &amp;lt;tt&amp;gt;sfprep4plot&amp;lt;/tt&amp;gt;, courtesy of Joachim Mispel, is shown below:&lt;br /&gt;
&lt;br /&gt;
[[Image:sf_prep4plot.jpg]]&lt;br /&gt;
&lt;br /&gt;
==sfcsv2rsf==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a delimited-text ASCII file to RSF binary floating point or int.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcsv2rsf help=n delimiter=, dtype=float verb=n debug=n trunc=n o1=0. o2=0. d1=1. d2=1. unit1=unknown unit2=unknown label1=unknown label2=unknown&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Zeros will be added if number of elements is not the same in each row.&amp;lt;br&amp;gt;n1 and n2 are computed automatically. For consistency with sfdisfil and &amp;lt;br&amp;gt;sfmatmult, output is C-style order (row-first), i.e. rows in input file &amp;lt;br&amp;gt;become dimension-1 columns in output. Output encoding is native.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d2=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;debug=n&#039;&#039;&#039; ||  [y/n] || 	Extra verbosity for debugging&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;delimiter=,&#039;&#039;&#039; ||   || 	Separator between values in input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;dtype=float&#039;&#039;&#039; ||   || 	Input type&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;help=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o2=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trunc=n&#039;&#039;&#039; ||  [y/n] || 	Truncate or add zeros if nr elems in rows differs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Whether to echo n1, n2, infill/truncation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A small usage example follow below. First, create an input file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ echo -e &#039;5,6,8,9.2\n11,124,5,0,1&#039; | tee file.csv&lt;br /&gt;
5,6,8,9.2&lt;br /&gt;
11,124,5,0,1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may notice that the number of values in each row is different.&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;tt&amp;gt;sfcsv2rsf&amp;lt;/tt&amp;gt;. Notice that no options are needed. By default, zeros will be appended to make the rows equal length:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf &amp;gt; junk.rsf ; sfdisfil &amp;lt; junk.rsf &lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that sfdisfil displays in column order (i.e. matrix is transposed if the number of rows is right). The dimensions of the file are actually transposed on disk:&lt;br /&gt;
&lt;br /&gt;
$ sfin junk.rsf&lt;br /&gt;
junk.rsf:&lt;br /&gt;
    in=&amp;quot;/data/path/junk.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          unit1=&amp;quot;unknown&amp;quot; &lt;br /&gt;
    n2=2           d2=1           o2=0          unit2=&amp;quot;unknown&amp;quot; &lt;br /&gt;
	10 elements 40 bytes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may want to run the output through &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt;, depending on your needs. However, if creating an input for &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt;, this will not be necessary, because &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt; is made to work with matrices that are displayed with &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt;, and takes as input a transpose matrix.&lt;br /&gt;
&lt;br /&gt;
Pipes can be used, of course, to skip the creation of intermediary files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf | sfdisfil&lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that since this program does not need any arguments (just stdin and stdout), when called with no arguments it will not display the man page. In order to consult the automatically generated documentation, you need to pass the option &amp;lt;tt&amp;gt;help=y&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
=user/jennings programs=&lt;br /&gt;
==sfsizes==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display the size of RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsizes files=y human=n file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Prints the element size, number of elements, and number of bytes&amp;lt;br&amp;gt;for a list of RSF files.  Non-RSF files are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;files=y&#039;&#039;&#039; ||  [y/n] || 	If y, print size of each file.  If n, print only total.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;human=n&#039;&#039;&#039; ||  [y/n] || 	If y, print human-readable file size.  If n, print byte count.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This program computes the &amp;quot;theoretical&amp;quot; size in bytes of the data fork of RSF files.  The actual space occupied on disk may be different and machine dependent due to disk blocking factors, etc.  This theoretical array size should be reproducible.  It is also fast because the program only reads the RSF headers files, not the actual data.&lt;br /&gt;
&lt;br /&gt;
For example, to get the total size of all RSF files in a directory, in human readable format, without listing each file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will also work because sfsizes simply skips any non-RSF file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sffiglist==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Compare Vplot files in Fig and Lock directories&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffiglist figdir= lockdir= list= show=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |&lt;br /&gt;
Parameter &#039;&#039;&#039;figdir&#039;&#039;&#039; is path to Fig directory, default is ./Fig.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;lockdir&#039;&#039;&#039; is path to Lock directory:&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is not in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFALTFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;list&#039;&#039;&#039; controls files to list, default is all.&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;show&#039;&#039;&#039; controls files to flip with sfpen, default is none.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = none (No files, print only summary.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = diff (Files that are different, determined by sfvplotdiff.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = miss (Files missing from figdir or lockdir, and different files.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = all (All files.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;File list codes:&lt;br /&gt;
&amp;lt;br&amp;gt;space   indicates files that are the same.&lt;br /&gt;
&amp;lt;br&amp;gt;  -     indicates file in lockdir that is missing from figdir.&lt;br /&gt;
&amp;lt;br&amp;gt;  +     indicates extra file in figdir that is missing from lockdir.&lt;br /&gt;
&amp;lt;br&amp;gt;number  is return code from sfvplotdiff indicating different files.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;figdir=&#039;&#039;&#039; ||   || 	fig directory, default = ./Fig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;list=&#039;&#039;&#039; ||   || 	how much to list [none,diff,miss,all], default = all&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;lockdir=&#039;&#039;&#039; ||   || 	lock directory, default = lock counterpart of figdir&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;show=&#039;&#039;&#039; ||   || 	how much to show [none,diff,miss,all], default = none&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tool lists Vplot files in &amp;quot;Fig&amp;quot; and &amp;quot;Lock&amp;quot; directories and compares them using sfvplotdiff.&lt;br /&gt;
&lt;br /&gt;
The Fig directory defaults to ./Fig and the Lock directory defaults to the  &lt;br /&gt;
corresponding directory where &amp;quot;scons lock&amp;quot; puts things, but either  &lt;br /&gt;
default can be overridden with the user parameters &#039;&#039;&#039;figdir&#039;&#039;&#039; and &#039;&#039;&#039;lockdir&#039;&#039;&#039; so that, for example,  &lt;br /&gt;
files in two different Fig directories can be compared.&lt;br /&gt;
&lt;br /&gt;
The default for the Lock directory has some logic to look in $RSFFIGS  &lt;br /&gt;
when Fig is in $RSFSRC/book, or to look in $RSFALTFIGS when Fig is not  &lt;br /&gt;
in $RSFSRC/book because I like to keep two different Lock directories:  &lt;br /&gt;
one for stuff in book and another for my own stuff that is not in  &lt;br /&gt;
book.  However, I tried to make the code default to reasonable things  &lt;br /&gt;
if any of these environment variables are not defined.&lt;br /&gt;
&lt;br /&gt;
The tool gives a summary count of files that are the same, files that  &lt;br /&gt;
are different, files in Fig that are missing from Lock, and files in  &lt;br /&gt;
Lock that are missing from Fig.&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;list&#039;&#039;&#039; (default=all) and &#039;&#039;&#039;show&#039;&#039;&#039; (default=none) control which files are listed or &amp;quot;flipped&amp;quot; with sfpen.  The file listing indicates which files are the same, which are different, and which are missing from Fig or Lock.&lt;br /&gt;
&lt;br /&gt;
For example, to list all the Vplot files in Fig and Lock:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To list all Vplot files and flip only files that are different:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all show=diff&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/psava programs=&lt;br /&gt;
&lt;br /&gt;
==sfawefd2d==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | acoustic time-domain FD modeling &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfawefd &amp;lt; Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf &amp;gt; Fdat.rsf den=Fden.rsf ompchunk=1 ompnth=0 verb=n snap=n free=n expl=n jdata=1 jsnap=nt nq1=sf_n(a1) nq2=sf_n(a2) oq1=sf_o(a1) oq2=sf_o(a2)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;den=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;expl=n&#039;&#039;&#039; ||  [y/n] || 	&amp;quot;exploding reflector&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;free=n&#039;&#039;&#039; ||  [y/n] || 	free surface flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jdata=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jsnap=nt&#039;&#039;&#039; ||   || 	save wavefield every *jsnap* time steps&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq1=sf_n(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq2=sf_n(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   || 	OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   || 	OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq1=sf_o(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq2=sf_o(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rec=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;snap=n&#039;&#039;&#039; ||  [y/n] || 	wavefield snapshots flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;sou=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;vel=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;wfl=&#039;&#039;&#039; ||   || 	auxiliary output file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
An example will be demonstrated below on a model with nx=nz=200, dx=dz=4m (size: 800x800m). There are two layers: the first one is 100x200 samples in (z,x) and the velocity is 1500m/s; the second layer has the same dimension and the velocity is 3000m/s. Density is set to 1 for the whole grid. A source and a receiver are co-located at x=400 and z=100. The full wavefield for the entire model aperture will be saved every 10th time step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
# Velocity model:&lt;br /&gt;
sfspike &amp;gt;Fvel.rsf mag=1500,3000 nsp=2 k1=1,101 l1=100,200 d1=4 d2=4 \&lt;br /&gt;
label1=z label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Density model:&lt;br /&gt;
sfspike &amp;gt;Fden.rsf mag=1 nsp=1 k1=1 l1=200 d1=4 d2=4 label1=z \&lt;br /&gt;
label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Source position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Fsou.rsf&lt;br /&gt;
&lt;br /&gt;
# Receiver position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Frec.rsf&lt;br /&gt;
&lt;br /&gt;
# Source wavelet:&lt;br /&gt;
sfspike nsp=1 n1=2000 d1=0.0005 k1=200 | sfricker1 frequency=20 |\&lt;br /&gt;
sftransp &amp;gt;Fwav.rsf&lt;br /&gt;
&lt;br /&gt;
# Creating data at specified receiver + saving full wavefield every 10th step:&lt;br /&gt;
sfawefd2d &amp;lt;Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf \&lt;br /&gt;
den=Fden.rsf &amp;gt;Fdat.rsf verb=y free=y expl=y snap=y dabc=y jdata=1 jsnap=10&lt;br /&gt;
echo &#039;label1=z unit1=m label2=x unit2=m&#039; &amp;gt;&amp;gt; Fwfl.rsf&lt;br /&gt;
&lt;br /&gt;
# View the wavefield movie:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfgrey gainpanel=a pclip=99 color=j scalebar=y | sfpen &lt;br /&gt;
&lt;br /&gt;
# View a wavefield snapshot:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfwindow f3=80 n3=1 |\&lt;br /&gt;
sfgrey pclip=99 color=j title=&#039;snapshot at t=0.4s&#039; |\&lt;br /&gt;
sfpen &lt;br /&gt;
&lt;br /&gt;
# View the data recorded at receiver:&lt;br /&gt;
&amp;lt;Fdat.rsf sfwindow |\&lt;br /&gt;
sfgraph title=&#039;Data recorded at receiver&#039; unit2=&#039;&#039; label2=amplitude |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:sfawefd_wfld.jpg|frame|center|sfawefd wavefield screenshot]]&lt;br /&gt;
[[Image:sfawefd_dat.png|frame|center|sfawefd data screenshot]]&lt;br /&gt;
&lt;br /&gt;
Attention: time steps that are too large can result in numerical instability.&lt;br /&gt;
&lt;br /&gt;
==sfsrmig3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 3-D S/R migration with extended SSF&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsrmig3 slo=Fs_s.rsf sls=Fs_r.rsf &amp;lt; Fw_s.rsf rwf=Fw_r.rsf &amp;gt; Fi.rsf cig=Fc.rsf ompchunk=1 ompnth=0 verb=y eps=0.01 twoway=n nrmax=1 dtmax=0.004 pmx=0 pmy=0 tmx=0 tmy=0 vpvs=1. hsym=n nht=1 oht=0 dht=0.1 nht=1 oht=0 dht=0.1 hsym=n nhh=1 ohh=0 dhh=0.1 nha=180 oha=0 dha=2.0 nhb=180 ohb=0 dhb=2.0 itype=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;cig=&#039;&#039;&#039; ||   ||     auxiliary output file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dha=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhb=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhh=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dht=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dtmax=0.004&#039;&#039;&#039; ||   ||      max time error&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;eps=0.01&#039;&#039;&#039; ||   ||         stability parameter&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;hsym=n&#039;&#039;&#039; ||  [y/n] ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;itype=&#039;&#039;&#039; ||   ||   imaging condition type&lt;br /&gt;
:o = zero lag (default)&lt;br /&gt;
:e = extended&lt;br /&gt;
:x = space-lags&lt;br /&gt;
:h = space-lags magnitude&lt;br /&gt;
:t = time-lag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nha=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhb=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhh=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nht=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nrmax=1&#039;&#039;&#039; ||   ||  max number of refs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oha=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohb=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohh=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oht=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   ||       OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   ||         OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmx=0&#039;&#039;&#039; ||   ||    padding on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmy=0&#039;&#039;&#039; ||   ||    padding on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rwf=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;slo=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;sls=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmx=0&#039;&#039;&#039; ||   ||    taper on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmy=0&#039;&#039;&#039; ||   ||    taper on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;twoway=n&#039;&#039;&#039; ||  [y/n] ||    two-way traveltime&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=y&#039;&#039;&#039; ||  [y/n] ||      verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vpvs=1.&#039;&#039;&#039; ||   ||  Vp/Vs ratio&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This program performs 3-D and 2-D shot-record (a.k.a. shot-profile) migration with an extended Split-Step Fourier (SSF) extrapolator with multiple reference velocities (hence &amp;quot;extended&amp;quot;). It takes as input a shot wavefield (&amp;lt;tt&amp;gt;stdin&amp;lt;/tt&amp;gt;), receiver wavefield (&amp;lt;tt&amp;gt;rwf=&amp;lt;/tt&amp;gt;) and slowness model (&amp;lt;tt&amp;gt;slo=&amp;lt;/tt&amp;gt;). Outputs are an image (&amp;lt;tt&amp;gt;stdout&amp;lt;/tt&amp;gt;) and a cube of Common Image Gathers (&amp;lt;tt&amp;gt;cig=&amp;lt;/tt&amp;gt;). An important parameter is &amp;lt;tt&amp;gt;nrmax&amp;lt;/tt&amp;gt;, the number of reference velocities. Its default value is 1, but for reasonable results it should be 5 or so. It is also good to specify nonzero taper values (&amp;lt;tt&amp;gt;tmx&amp;lt;/tt&amp;gt; and, for 3-D, &amp;lt;tt&amp;gt;tmy&amp;lt;/tt&amp;gt; as well). The values of padding parameters &amp;lt;tt&amp;gt;pmx&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;pmy&amp;lt;/tt&amp;gt; are split in two by the program, i.e. if your data x axis is 501-points long, specify pmx=11 to get a value of 512 that will result in fast Fourier Transforms. &lt;br /&gt;
&lt;br /&gt;
The program will also migrate converted-wave data if a file with the S-wave slowness model (&amp;lt;tt&amp;gt;sls=&amp;lt;/tt&amp;gt;) is provided.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; parameter is only used when &amp;lt;tt&amp;gt;itype=h&amp;lt;/tt&amp;gt;. Do not specify a &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; value unless you know really well what you are doing.&lt;br /&gt;
&lt;br /&gt;
===Usage example===&lt;br /&gt;
The commands below, slightly modified from [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/data/sigsbee/ptest/SConstruct?revision=3993&amp;amp;view=markup RSFSRC/book/data/sigsbee/ptest], show how to prepare the [http://www.reproducibility.org/RSF/book/data/sigsbee Sigsbee 2A] data and velocity for migration.&lt;br /&gt;
&lt;br /&gt;
Convert input data (shots) from SEG-Y to RSF:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_nfs.segy tfile=tdata.rsf hfile=/dev/null bfile=/dev/null &amp;gt; ddata.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Convert trace headers to float (required by &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; tdata.rsf sfdd type=float &amp;gt; trchdr.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Shot positions:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;fldr + 10925/150&amp;quot; | sfwindow squeeze=y &amp;gt; tsi.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Extract offset positions from the trace header files, eliminate length-1 axis, scale, create a header for binning (required by &amp;lt;tt&amp;gt;sfintbin&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;offset&amp;quot; |\&lt;br /&gt;
sfwindow squeeze=y |\&lt;br /&gt;
sfmath output=&amp;quot;input/75&amp;quot; |\&lt;br /&gt;
sfcat axis=2 space=n tsi.rsf |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfdd type=int &amp;gt; tos.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Binning and muting:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; ddata.rsf sfintbin head=tos.rsf xkey=0 ykey=1 |\&lt;br /&gt;
sfput label1=Time unit1=s d2=0.075 o2=0.0 label2=hx d3=0.150 o3=10.925 label3=sx |\&lt;br /&gt;
sfmutter half=false t0=1.0 v0=6.0 |\&lt;br /&gt;
sfput d2=0.02286 o2=0 unit2=km d3=0.04572 o3=3.32994 unit3=km &amp;gt; shots.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Keeping only 20 shots so that this 1-node job will not take forever, FFT-ing, decimating frequency slices (same as shortening the time axis), and creating y and hy axes of length 1:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; shots.rsf sfwindow n3=20 f3=10 j3=20 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfspray axis=3 n=1 o=0 d=1 label=hy |\&lt;br /&gt;
sfspray axis=5 n=1 o=0 d=1 label=sy &amp;gt; rfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The dimensions of the cube thus created are:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin rfft.rsf trail=n&lt;br /&gt;
rfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;Frequency&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n2=348         d2=0.02286     o2=0          label2=&amp;quot;hx&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=1           d3=1           o3=0          label3=&amp;quot;hy&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
    n4=20          d4=0.9144      o4=3.78714    label4=&amp;quot;sx&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        1392000 elements 11136000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create the source wavelet (limited to the same frequency band as the data) and Fourier transform it:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike k1=1 n1=1500 d1=0.008 |\&lt;br /&gt;
sfbandpass flo=15 fhi=25 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfput label1=freq &amp;gt; sfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a frequency-domain wavelet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin sfft.rsf&lt;br /&gt;
sfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/sfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;freq&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
        200 elements 1600 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create &amp;quot;synched&amp;quot; source and receiver wavefields with &amp;lt;tt&amp;gt;srsyn&amp;lt;/tt&amp;gt; from wavelet and data frequency slices. Basically both the receiver and shot frequency slices are &amp;quot;placed&amp;quot; at the right location and padded with zeros up to the dimension of the x axis specified below.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rfft.rsf sfsrsyn nx=1067 dx=0.02286 ox=3.05562 wav=sfft.rsf swf=swav.rsf &amp;gt; rwav.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates frequency slices ready for migration for both source and receiver, only axis 1 (frequency) must become axis 3, for both datasets:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; swav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; stra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rwav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; rtra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a surface receiver wavefield ready for input to migration. Axis 4 is shot number. The values of axis 4 are arbitrary because each shot has been padded with zeros so that it covers the entire velocity model. Therefore the aperture of the downward continuation for each shot will be as large as the survey.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin trail=n rtra.rsf&lt;br /&gt;
rtra.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rtra.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=200         d3=0.25        o3=1          label3=&amp;quot;w&amp;quot; unit3=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n4=20          d4=1           o4=0          label4=&amp;quot;e&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        4268000 elements 34144000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Convert the velocity model from SEG-Y to RSF, decimate, convert from feet to km, transpose, convert to slowness and insert an additional axis:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_migvel.sgy tfile=/dev/null hfile=/dev/null bfile=/dev/null |\&lt;br /&gt;
sfput o1=0 d1=0.00762 label1=z unit1=km o2=3.05562 d2=0.01143 label2=x unit2=km |\&lt;br /&gt;
sfwindow j1=4 j2=2 |\&lt;br /&gt;
sfscale rscale=0.0003048 |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfmath output=&amp;quot;1/input&amp;quot; |\&lt;br /&gt;
sfspray axis=2 n=1 d=1 o=0 |\&lt;br /&gt;
sfput label2=y &amp;gt; slow.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a slowness file ready for input to migration, with an x axis identical to the x axis of the wavefield files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin slow.rsf&lt;br /&gt;
slow.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slow.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, the migration command (for a 4-processor machine, hence the &amp;lt;tt&amp;gt;ompnth&amp;lt;/tt&amp;gt; value). We choose not to compute any image gathers (&amp;lt;tt&amp;gt;itype=o&amp;lt;/tt&amp;gt;), but due to the construction of the program we still have to explicitly assign the &amp;lt;tt&amp;gt;cig&amp;lt;/tt&amp;gt; tag, or else a RSF file with the name of the tag and no rsf extension will be created:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; stra.rsf sfsrmig3 nrmax=20 dtmax=5e-05 eps=0.01 verb=y ompnth=4 \&lt;br /&gt;
tmx=16 rwf=rtra.rsf slo=slow.rsf itype=o cig=/dev/null &amp;gt; img.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The migration of 20 shots takes approximately 3 hours on a 4-processor machine (1 shot=9 minutes). Without the frequency slice decimation by a factor of 3 and the depth axis decimation by a factor of 4, it would have taken twelve times as much. The resulting image has a y axis of length 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin img.rsf trail=n&lt;br /&gt;
img.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/img.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To properly visualize the image, we need to eliminate the axis of length 1, then transpose the x and z axes to their natural position:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;img.rsf sfwindow squeeze=y | sftransp | sfgrey &amp;gt; img.vpl&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Madagascar_Code_Patterns&amp;diff=2025</id>
		<title>Madagascar Code Patterns</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Madagascar_Code_Patterns&amp;diff=2025"/>
		<updated>2011-10-29T01:20:22Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Loop over ensembles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All patterns are in C, unless otherwise noted.&lt;br /&gt;
&lt;br /&gt;
==Loop over ensembles==&lt;br /&gt;
This is a simple loop over reading 1-D arrays (&amp;quot;traces&amp;quot;), 2-D (&amp;quot;gathers&amp;quot;), etc.&lt;br /&gt;
&lt;br /&gt;
It is necessary in the case of algorithms that act on one ensemble at a time. Parallelizable with OMP.&lt;br /&gt;
&lt;br /&gt;
==I/O-optimized loop over samples==&lt;br /&gt;
===Description and usage===&lt;br /&gt;
It consists of looping over an entire dataset and applying a given procedure to every single sample in a dataset, regardless of what &amp;quot;trace&amp;quot;/&amp;quot;frame&amp;quot;/&amp;quot;volume&amp;quot; it belongs to. Example: computing the sum of all elements of a dataset; computing a histogram; performing a clip operation; etc. It uses the BUFSIZ macro defined in &amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; to ensure efficient stream I/O. Its occurences can be easily found by grepping for BUFSIZ in the codebase.&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
int n; /* Total number of elements in dataset */&lt;br /&gt;
int nbuf; /* Number of elements in I/O buffer */&lt;br /&gt;
float *fbuf; /* I/O array */&lt;br /&gt;
sf_file in=NULL; /* Input file. Here is stdin, but this is not compulsory */&lt;br /&gt;
&lt;br /&gt;
in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
n = sf_filesize(in);&lt;br /&gt;
&lt;br /&gt;
/* This example uses float as data type. &lt;br /&gt;
Any other data type (int, sf_complex, etc) can be used, as appropriate */&lt;br /&gt;
nbuf = BUFSIZ/sizeof(float);&lt;br /&gt;
&lt;br /&gt;
fbuf = sf_floatalloc(nbuf);&lt;br /&gt;
&lt;br /&gt;
for (; n &amp;gt; 0; n -= nbuf) {&lt;br /&gt;
&lt;br /&gt;
    if (nbuf &amp;gt; n) nbuf = n;&lt;br /&gt;
&lt;br /&gt;
    sf_floatread(fbuf, nbuf, in);&lt;br /&gt;
&lt;br /&gt;
    for (i=0; i &amp;lt; nbuf; i++) {&lt;br /&gt;
        /* Do computations here */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Potential for improvement===&lt;br /&gt;
This pattern should be parallelized using OpenMP.&lt;br /&gt;
&lt;br /&gt;
The [http://www.delorie.com/gnu/docs/glibc/libc_226.html GNU C Library documentation] states that when doing I/O on a file (as opposed to a stream), the &amp;lt;tt&amp;gt;st_blksize&amp;lt;/tt&amp;gt; field of the file attributes is a better choice than &amp;lt;tt&amp;gt;BUFSIZ&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==OMP parallelized loop==&lt;br /&gt;
===Description and usage===&lt;br /&gt;
Shared-memory parallelization using the [https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] library.&lt;br /&gt;
===Example===&lt;br /&gt;
===Potential for improvement===&lt;br /&gt;
&lt;br /&gt;
==Parallelized, I/O-optimized loop over samples==&lt;br /&gt;
===Description and usage===&lt;br /&gt;
===Example===&lt;br /&gt;
===Potential for improvement===&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Madagascar_Code_Patterns&amp;diff=2024</id>
		<title>Madagascar Code Patterns</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Madagascar_Code_Patterns&amp;diff=2024"/>
		<updated>2011-10-29T01:16:15Z</updated>

		<summary type="html">&lt;p&gt;Nick: /*Loop over ensembles */ vulnerability&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All patterns are in C, unless otherwise noted.&lt;br /&gt;
&lt;br /&gt;
==Loop over ensembles==&lt;br /&gt;
This is a simple loop over reading 1-D arrays (&amp;quot;traces&amp;quot;), 2-D (&amp;quot;gathers&amp;quot;), etc.&lt;br /&gt;
&lt;br /&gt;
It is necessary in the case of algorithms that act on one ensemble at a time. Parallelizable with OMP.&lt;br /&gt;
&lt;br /&gt;
It has the potential bug that the ensemble array is allocated using dimensions that are of type int (usually 4-byte). This will overflow on some rare occasions, and they should either be defined as 8-byte, or there should be a check function in which dimensions are read into a 8-byte int type and checked whether they will overflow the int. A different function than sf_histint needs to be created for this purpose, or the check to be implemented inside sf_histint.&lt;br /&gt;
&lt;br /&gt;
==I/O-optimized loop over samples==&lt;br /&gt;
===Description and usage===&lt;br /&gt;
It consists of looping over an entire dataset and applying a given procedure to every single sample in a dataset, regardless of what &amp;quot;trace&amp;quot;/&amp;quot;frame&amp;quot;/&amp;quot;volume&amp;quot; it belongs to. Example: computing the sum of all elements of a dataset; computing a histogram; performing a clip operation; etc. It uses the BUFSIZ macro defined in &amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; to ensure efficient stream I/O. Its occurences can be easily found by grepping for BUFSIZ in the codebase.&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
int n; /* Total number of elements in dataset */&lt;br /&gt;
int nbuf; /* Number of elements in I/O buffer */&lt;br /&gt;
float *fbuf; /* I/O array */&lt;br /&gt;
sf_file in=NULL; /* Input file. Here is stdin, but this is not compulsory */&lt;br /&gt;
&lt;br /&gt;
in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
n = sf_filesize(in);&lt;br /&gt;
&lt;br /&gt;
/* This example uses float as data type. &lt;br /&gt;
Any other data type (int, sf_complex, etc) can be used, as appropriate */&lt;br /&gt;
nbuf = BUFSIZ/sizeof(float);&lt;br /&gt;
&lt;br /&gt;
fbuf = sf_floatalloc(nbuf);&lt;br /&gt;
&lt;br /&gt;
for (; n &amp;gt; 0; n -= nbuf) {&lt;br /&gt;
&lt;br /&gt;
    if (nbuf &amp;gt; n) nbuf = n;&lt;br /&gt;
&lt;br /&gt;
    sf_floatread(fbuf, nbuf, in);&lt;br /&gt;
&lt;br /&gt;
    for (i=0; i &amp;lt; nbuf; i++) {&lt;br /&gt;
        /* Do computations here */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Potential for improvement===&lt;br /&gt;
This pattern should be parallelized using OpenMP.&lt;br /&gt;
&lt;br /&gt;
The [http://www.delorie.com/gnu/docs/glibc/libc_226.html GNU C Library documentation] states that when doing I/O on a file (as opposed to a stream), the &amp;lt;tt&amp;gt;st_blksize&amp;lt;/tt&amp;gt; field of the file attributes is a better choice than &amp;lt;tt&amp;gt;BUFSIZ&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==OMP parallelized loop==&lt;br /&gt;
===Description and usage===&lt;br /&gt;
Shared-memory parallelization using the [https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] library.&lt;br /&gt;
===Example===&lt;br /&gt;
===Potential for improvement===&lt;br /&gt;
&lt;br /&gt;
==Parallelized, I/O-optimized loop over samples==&lt;br /&gt;
===Description and usage===&lt;br /&gt;
===Example===&lt;br /&gt;
===Potential for improvement===&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Windows&amp;diff=2011</id>
		<title>Windows</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Windows&amp;diff=2011"/>
		<updated>2011-10-17T01:06:47Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Screenshots */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; has been run on Microsoft Windows machines under various types of environments:&lt;br /&gt;
&lt;br /&gt;
==Cygwin==&lt;br /&gt;
&lt;br /&gt;
[[Image:cygwin-icon.gif|left|]] &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; can run under [http://cygwin.com Cygwin], which provides a Unix environment under Windows.&lt;br /&gt;
&lt;br /&gt;
To obtain Cygwin, go to its web page, download and run the installer. This should create a Cygwin program, which when run, creates a POSIX shell window similar-looking to the Windows command window but which behaves in a more Unix-like way.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039;: If you are unfamiliar with Unix-like systems, a good place to start is Greg Wilson&#039;s [http://www.osl.iu.edu/~lums/swc/www/shell.html Software Carpentry] course. &lt;br /&gt;
&lt;br /&gt;
You will need to install several additional Cygwin components before Madagascar can run. To get these, rerun the installer program (called &#039;&#039;&#039;Setup&#039;&#039;&#039; and represented by an icon with a black &amp;quot;C&amp;quot; shape enclosing a green arrow). &lt;br /&gt;
&lt;br /&gt;
# Start &#039;&#039;&#039;Setup&#039;&#039;&#039; program. &lt;br /&gt;
# Keep clicking (defaults should work, but you can choose a mirror on your own continent) until you see a collapsed list (boxed &amp;quot;+&amp;quot; signs) in a selection box. &lt;br /&gt;
# Choose the following before downloading.&lt;br /&gt;
## Open the &#039;&#039;&#039;Devel&#039;&#039;&#039; section and select&lt;br /&gt;
##* gcc&lt;br /&gt;
##* make&lt;br /&gt;
## If you want to use the development version of &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt;, also choose&lt;br /&gt;
##* subversion&lt;br /&gt;
## If you have a favorite unix editor, choose it under &#039;&#039;&#039;Editors&#039;&#039;&#039; (novices may wish to work with Notepad for a while). Both &amp;lt;tt&amp;gt;vim&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; are available.&lt;br /&gt;
## Open &#039;&#039;&#039;Interpreters&#039;&#039;&#039; and select&lt;br /&gt;
##* python&lt;br /&gt;
## Open &#039;&#039;&#039;Net&#039;&#039;&#039; and select&lt;br /&gt;
##* sunrpc&lt;br /&gt;
## Open &#039;&#039;&#039;Libs&#039;&#039;&#039; and select&lt;br /&gt;
##* opengl&lt;br /&gt;
## If you intend to use X-window, open &#039;&#039;&#039;X11&#039;&#039;&#039; and select&lt;br /&gt;
##* libX11-devel&lt;br /&gt;
##* libXaw-devel&lt;br /&gt;
## If you intend to use LaTeX, open &#039;&#039;&#039;Publishing&#039;&#039;&#039; and select&lt;br /&gt;
##* tetex&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;ppmpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libnetpbm-devel&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;tiffpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libtiff-devel&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;gdpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libgd-devel&lt;br /&gt;
# Next, click &#039;&#039;&#039;Next&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
#: Your download will proceed.&lt;br /&gt;
# When done, click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
After performing this steps, proceed to a normal Madagascar [[Installation]].&lt;br /&gt;
&lt;br /&gt;
For running X applications such as &#039;&#039;&#039;xtpen&#039;&#039;&#039;, make sure to run &#039;&#039;&#039;startx&#039;&#039;&#039; first to open an X terminal window.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
&lt;br /&gt;
If you get errors &amp;quot;unable to remap...&amp;quot;, note the following:&lt;br /&gt;
&lt;br /&gt;
A proper work of a Cygwin installation may require running &#039;&#039;&#039;rebaseall&#039;&#039;&#039;, a program that fixes library dependencies. You only need to run it once.&lt;br /&gt;
# Quit all Cygwin processes&lt;br /&gt;
# Start &#039;&#039;&#039;ash&#039;&#039;&#039; (&amp;lt;tt&amp;gt;&amp;lt;cygroot&amp;gt;\bin\ash.exe&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Execute &amp;lt;tt&amp;gt;/usr/bin/rebaseall&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Screenshots===&lt;br /&gt;
&lt;br /&gt;
* Running Cygwin&#039;s &#039;&#039;&#039;setup&#039;&#039;&#039; program&lt;br /&gt;
&lt;br /&gt;
[[Image:setup.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Selecting packages&lt;br /&gt;
&lt;br /&gt;
[[Image:select.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Running Cygwin&#039;s &#039;&#039;&#039;bash&#039;&#039;&#039; program&lt;br /&gt;
&lt;br /&gt;
[[Image:bash.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Testing &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; installation&lt;br /&gt;
&lt;br /&gt;
[[Image:test.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[Image:welcome.png|600px]]&lt;br /&gt;
===Matlab API===&lt;br /&gt;
To use the Matlab API with Madagascar under Cygwin, make sure you have Mex installed, and create a symbolic link, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /location/of/mex.bat /usr/bin/mex &lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Interix==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Interix Interix] is the name of the Unix environment for Windows provided by Microsoft through the following software packages:&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Microsoft_Windows_Services_for_UNIX Services For Unix] (SFU), available as a [http://www.microsoft.com/downloads/details.aspx?FamilyID=896c9688-601b-44f1-81a4-02878ff11778&amp;amp;DisplayLang=en free download] for the Windows NT family of operating systems up to and including Windows XP Professional ([http://www.reproducibility.org/rsflog/uploads/PS0001.jpg screenshot of m8r running on SFU] from an [http://www.reproducibility.org/rsflog/index.php?/archives/68-RSFMadagascar-on-Windows-using-SFU.html April 2006 entry on the m8r blog]). SFU availability was discontinued in 2009.&lt;br /&gt;
* [http://technet.microsoft.com/en-us/library/cc779522.aspx Subsystem for UNIX-based Applications] (SUA), included with Windows Server 2003 R2 and Windows Vista.&lt;br /&gt;
&lt;br /&gt;
==SSH + X server==&lt;br /&gt;
If you can count on a network connection to a full UNIX machine while you run Madagascar, you actually need to install under MS Windows just a SSH client and a X server, and just run the Madagascar installed on the UNIX machine. Cygwin provides both, but it is big and slow. Faster and more lightweight alternatives are:&lt;br /&gt;
* [http://mobaxterm.mobatek.net/en/ MobaXterm], an enhanced terminal with an X server and a set of Unix commands (GNU/Cygwin) packaged in a single portable exe file;&lt;br /&gt;
* [http://sourceforge.net/projects/xming/ Xming] as X server and [http://en.wikipedia.org/wiki/PuTTY PuTTY] as SSH client (remember to check the &amp;quot;Tunnel X11 connections&amp;quot; box when saving the session configuration).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Windows&amp;diff=2010</id>
		<title>Windows</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Windows&amp;diff=2010"/>
		<updated>2011-10-17T01:04:55Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Pictures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; has been run on Microsoft Windows machines under various types of environments:&lt;br /&gt;
&lt;br /&gt;
==Cygwin==&lt;br /&gt;
&lt;br /&gt;
[[Image:cygwin-icon.gif|left|]] &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; can run under [http://cygwin.com Cygwin], which provides a Unix environment under Windows.&lt;br /&gt;
&lt;br /&gt;
To obtain Cygwin, go to its web page, download and run the installer. This should create a Cygwin program, which when run, creates a POSIX shell window similar-looking to the Windows command window but which behaves in a more Unix-like way.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039;: If you are unfamiliar with Unix-like systems, a good place to start is Greg Wilson&#039;s [http://www.osl.iu.edu/~lums/swc/www/shell.html Software Carpentry] course. &lt;br /&gt;
&lt;br /&gt;
You will need to install several additional Cygwin components before Madagascar can run. To get these, rerun the installer program (called &#039;&#039;&#039;Setup&#039;&#039;&#039; and represented by an icon with a black &amp;quot;C&amp;quot; shape enclosing a green arrow). &lt;br /&gt;
&lt;br /&gt;
# Start &#039;&#039;&#039;Setup&#039;&#039;&#039; program. &lt;br /&gt;
# Keep clicking (defaults should work, but you can choose a mirror on your own continent) until you see a collapsed list (boxed &amp;quot;+&amp;quot; signs) in a selection box. &lt;br /&gt;
# Choose the following before downloading.&lt;br /&gt;
## Open the &#039;&#039;&#039;Devel&#039;&#039;&#039; section and select&lt;br /&gt;
##* gcc&lt;br /&gt;
##* make&lt;br /&gt;
## If you want to use the development version of &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt;, also choose&lt;br /&gt;
##* subversion&lt;br /&gt;
## If you have a favorite unix editor, choose it under &#039;&#039;&#039;Editors&#039;&#039;&#039; (novices may wish to work with Notepad for a while). Both &amp;lt;tt&amp;gt;vim&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; are available.&lt;br /&gt;
## Open &#039;&#039;&#039;Interpreters&#039;&#039;&#039; and select&lt;br /&gt;
##* python&lt;br /&gt;
## Open &#039;&#039;&#039;Net&#039;&#039;&#039; and select&lt;br /&gt;
##* sunrpc&lt;br /&gt;
## Open &#039;&#039;&#039;Libs&#039;&#039;&#039; and select&lt;br /&gt;
##* opengl&lt;br /&gt;
## If you intend to use X-window, open &#039;&#039;&#039;X11&#039;&#039;&#039; and select&lt;br /&gt;
##* libX11-devel&lt;br /&gt;
##* libXaw-devel&lt;br /&gt;
## If you intend to use LaTeX, open &#039;&#039;&#039;Publishing&#039;&#039;&#039; and select&lt;br /&gt;
##* tetex&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;ppmpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libnetpbm-devel&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;tiffpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libtiff-devel&lt;br /&gt;
## If you intend to use &amp;lt;tt&amp;gt;gdpen&amp;lt;/tt&amp;gt;, open &#039;&#039;&#039;Graphics&#039;&#039;&#039; and select&lt;br /&gt;
##* libgd-devel&lt;br /&gt;
# Next, click &#039;&#039;&#039;Next&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
#: Your download will proceed.&lt;br /&gt;
# When done, click &#039;&#039;&#039;Finish&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
After performing this steps, proceed to a normal Madagascar [[Installation]].&lt;br /&gt;
&lt;br /&gt;
For running X applications such as &#039;&#039;&#039;xtpen&#039;&#039;&#039;, make sure to run &#039;&#039;&#039;startx&#039;&#039;&#039; first to open an X terminal window.&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
&lt;br /&gt;
If you get errors &amp;quot;unable to remap...&amp;quot;, note the following:&lt;br /&gt;
&lt;br /&gt;
A proper work of a Cygwin installation may require running &#039;&#039;&#039;rebaseall&#039;&#039;&#039;, a program that fixes library dependencies. You only need to run it once.&lt;br /&gt;
# Quit all Cygwin processes&lt;br /&gt;
# Start &#039;&#039;&#039;ash&#039;&#039;&#039; (&amp;lt;tt&amp;gt;&amp;lt;cygroot&amp;gt;\bin\ash.exe&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# Execute &amp;lt;tt&amp;gt;/usr/bin/rebaseall&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Screenshots===&lt;br /&gt;
&lt;br /&gt;
* Running Cygwin&#039;s &#039;&#039;&#039;setup&#039;&#039;&#039; program&lt;br /&gt;
&lt;br /&gt;
[[Image:setup.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Selecting packages&lt;br /&gt;
&lt;br /&gt;
[[Image:select.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Running Cygwin&#039;s &#039;&#039;&#039;bash&#039;&#039;&#039; program&lt;br /&gt;
&lt;br /&gt;
[[Image:bash.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Testing &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; installation&lt;br /&gt;
&lt;br /&gt;
[[Image:test.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[Image:welcome.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==Interix==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Interix Interix] is the name of the Unix environment for Windows provided by Microsoft through the following software packages:&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Microsoft_Windows_Services_for_UNIX Services For Unix] (SFU), available as a [http://www.microsoft.com/downloads/details.aspx?FamilyID=896c9688-601b-44f1-81a4-02878ff11778&amp;amp;DisplayLang=en free download] for the Windows NT family of operating systems up to and including Windows XP Professional ([http://www.reproducibility.org/rsflog/uploads/PS0001.jpg screenshot of m8r running on SFU] from an [http://www.reproducibility.org/rsflog/index.php?/archives/68-RSFMadagascar-on-Windows-using-SFU.html April 2006 entry on the m8r blog]). SFU availability was discontinued in 2009.&lt;br /&gt;
* [http://technet.microsoft.com/en-us/library/cc779522.aspx Subsystem for UNIX-based Applications] (SUA), included with Windows Server 2003 R2 and Windows Vista.&lt;br /&gt;
&lt;br /&gt;
==SSH + X server==&lt;br /&gt;
If you can count on a network connection to a full UNIX machine while you run Madagascar, you actually need to install under MS Windows just a SSH client and a X server, and just run the Madagascar installed on the UNIX machine. Cygwin provides both, but it is big and slow. Faster and more lightweight alternatives are:&lt;br /&gt;
* [http://mobaxterm.mobatek.net/en/ MobaXterm], an enhanced terminal with an X server and a set of Unix commands (GNU/Cygwin) packaged in a single portable exe file;&lt;br /&gt;
* [http://sourceforge.net/projects/xming/ Xming] as X server and [http://en.wikipedia.org/wiki/PuTTY PuTTY] as SSH client (remember to check the &amp;quot;Tunnel X11 connections&amp;quot; box when saving the session configuration).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=2005</id>
		<title>Contributing new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=2005"/>
		<updated>2011-08-18T03:34:15Z</updated>

		<summary type="html">&lt;p&gt;Nick: suggestion to add info to NEWS.txt&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want to share your code with other Madagascar users:   &lt;br /&gt;
# Follow the guide on [[Adding new programs to Madagascar]].&lt;br /&gt;
# If your employer holds the copyright for your software, obtain a permission to distribute under a [http://www.gnu.org/copyleft/gpl.html GPL license] and  place a copyright and GPL license notice in each file with code. &lt;br /&gt;
# [http://sourceforge.net/account/registration/ Register at SourceForge].&lt;br /&gt;
# Find out who the project administrators are (Look for &amp;quot;Project Admins&amp;quot; on [http://sourceforge.net/projects/rsf/ this page]) and pass your SourceForge user name to one of them.&lt;br /&gt;
# Upload your directory to the repository using &amp;lt;tt&amp;gt;[http://svnbook.red-bean.com/en/1.0/re01.html svn add]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[http://svnbook.red-bean.com/en/1.1/re06.html svn commit]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Announce your changes in the release notes for the upcoming stable version ([http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/NEWS.txt?view=markup $RSFSRC/NEWS.txt])&lt;br /&gt;
# Make sure to add reproducible examples of using your program under the &amp;lt;tt&amp;gt;RSFSRC/book&amp;lt;/tt&amp;gt; tree. Create new directories if necessary and commit them to the repository. As a rule, programs without examples are not included in the release version.&lt;br /&gt;
&lt;br /&gt;
Some additional useful information is included below.&lt;br /&gt;
&lt;br /&gt;
==Repository procedure suggestions==&lt;br /&gt;
Please try to:&lt;br /&gt;
* Do [http://en.wikipedia.org/wiki/Atomic_commit atomic commits].&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;svn commit -m &amp;quot;your message here&amp;quot;&amp;lt;/tt&amp;gt; to let others know what changed.&lt;br /&gt;
** Alternatively, set the &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;SVN_EDITOR&amp;lt;/tt&amp;gt; environmental variables to your favorite editor and edit your message there.&lt;br /&gt;
* If you plan to do large-scale substantive changes, create a Subversion [http://en.wikipedia.org/wiki/Branching_(software) branch] by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn copy https://rsf.svn.sourceforge.net/svnroot/rsf/trunk https://rsf.svn.sourceforge.net/svnroot/rsf/yourbranchname&lt;br /&gt;
svn co https://rsf.svn.sourceforge.net/svnroot/rsf/yourbranchname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For coding style suggestions, please see [[Adding_new_programs_to_Madagascar#Style_guide | the &amp;quot;Adding new programs&amp;quot; section]]. &lt;br /&gt;
&lt;br /&gt;
==Backward compatibility features==&lt;br /&gt;
If you introduce or notice a feature that is used solely for backwards compatibility with an old version of a dependency, please document it here, so that the feature can be eliminated when the Madagascar community stops supporting that version of that dependency&amp;lt;ref&amp;gt;This could be more elegantly done by using a special string to flag a backwards compatibility comment in the code, then have the documentation builder build this list automatically. This would make it more likely for this page to be kept in synch with the codebase.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Python 2.2 and older===&lt;br /&gt;
* In &amp;lt;tt&amp;gt;framework/rsfdoc.py&amp;lt;/tt&amp;gt;: Everything in the &amp;lt;tt&amp;gt;have_datetime_module=False&amp;lt;/tt&amp;gt; branches&lt;br /&gt;
&lt;br /&gt;
===Python 2.3 and older===&lt;br /&gt;
* In &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt;: Everything in the &amp;lt;tt&amp;gt;have_subprocess=False&amp;lt;/tt&amp;gt; branches&lt;br /&gt;
* In &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt;: See code after comment &amp;quot;For Py 2.4 and up this can be done more elegantly...&amp;quot;&lt;br /&gt;
* In &amp;lt;tt&amp;gt;user/ivlad/ivlad.py&amp;lt;/tt&amp;gt;: Everything in the &amp;lt;tt&amp;gt;have_subprocess=False&amp;lt;/tt&amp;gt; branches&lt;br /&gt;
* The entire &amp;lt;tt&amp;gt;api/python/rsfbak.py&amp;lt;/tt&amp;gt; (also needed on systems which do not have recent versions of numpy &#039;&#039;and&#039;&#039; SWIG)&lt;br /&gt;
===Python 2.4 and older===&lt;br /&gt;
* try (try...except)... finally construct instead of try... except... finally in &amp;lt;tt&amp;gt;framework/rsfdoc.py&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mitigating missing dependencies==&lt;br /&gt;
The main idea is to attempt to provide [http://en.wikipedia.org/wiki/Graceful_degradation graceful degradation] when facing a missing dependency. Quoting the Wikipedia page on fault-tolerant systems, this &amp;quot;enables a system to continue operating properly in the event of the failure of (or one or more faults within) some of its components. If its operating quality decreases at all, the decrease is proportional to the severity of the failure, as compared to a naively-designed system in which even a small failure can cause total breakdown.&amp;quot;&lt;br /&gt;
===SWIG or numpy===&lt;br /&gt;
Graceful degradation is implemented. Please see the [[Advanced_Installation#Python API | Advanced Installation / Python API]] for an introduction to this issue. The module providing the limited functionality is &amp;lt;tt&amp;gt;api/python/rsfbak.py&amp;lt;/tt&amp;gt;, which emulates header and command-line parameter reading functions from headers from the &amp;quot;official&amp;quot; development kit. When writing a Python program manipulating headers, it may be tempting to write &amp;lt;tt&amp;gt;import rsfbak&amp;lt;/tt&amp;gt; because it is present anyway, but it is not a good idea. Use instead something like:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
try:&lt;br /&gt;
    import rsf&lt;br /&gt;
except: # Python devkit not installed&lt;br /&gt;
    import rsfbak as rsf&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
The reason is that the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; Python module is an interface to the homonymous C library, which ensures a unitary implementation of I/O throughout the package, and it should be used whenever possible. Having programs that do RSF I/O but never uses the official library practically forks the API, which is a Bad Thing. Using the pattern above ensures the alternate partial implementation is permanently synced with the principal implementation.&lt;br /&gt;
&lt;br /&gt;
==Reasons for the existence of certain features==&lt;br /&gt;
===Why pyc files are generated during the install step===&lt;br /&gt;
Python bytecode files, with the pyc extensions, are created during the &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; in order to:&lt;br /&gt;
* Register them in SCons&#039; dependency tree, so that they are removed by &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Avoid a situation in which a user tries to execute a Madagascar Python program, but creating the pyc file during a module import fails because of lack of write access to &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==cfortran.h==&lt;br /&gt;
This source code file provides a machine-independent interface between C procedures, Fortran procedures and global data (more details [http://www-zeus.desy.de/~burow/cfortran/ on the website of its initial author]). It is a dependency of the F77 and F90 APIs, as well as of vplot. It is included in m8r in &amp;lt;tt&amp;gt;api/f90&amp;lt;/tt&amp;gt; with a link in &amp;lt;tt&amp;gt;api/f77&amp;lt;/tt&amp;gt;. Version 4.3 (2002) is still distributed through the website of the original author. Another version (fork?) is [http://root.cern.ch/viewvc/trunk/montecarlo/eg/inc/cfortran.h?view=log maintained at CERN] and distributed in the include directory of the interface to event generators in the Monte Carlo libraries in the [http://cernlib.web.cern.ch/cernlib/ CERN Program Library] (CERNlib). Debian distributes the Free Software part of this package as &amp;lt;tt&amp;gt;cernlib&amp;lt;/tt&amp;gt;. Under Fedora, &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; is included in &amp;lt;tt&amp;gt;cernlib-g77-devel&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cernlib-devel&amp;lt;/tt&amp;gt;, which happily overwrite each other&#039;s files and create copies of &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; in two different locations deeply nested under &amp;lt;tt&amp;gt;/usr/include&amp;lt;/tt&amp;gt;. CERNlib&#039;s Debian maintainer states that [http://people.debian.org/~kmccarty/cernlib/index.html &amp;quot;CERNlib is an ancient mass of mostly Fortran code&amp;quot;] and that [http://people.debian.org/~kmccarty/physics-software-rant.html &amp;quot;Most components of CERNLIB are completely broken on modern 64-bit architectures&amp;quot;], so m8r developers should be aware that CERNlib will probably be superseded at some point in the future by [http://en.wikipedia.org/wiki/ROOT ROOT], with upstream &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; maintenance possibly continuing this way.&lt;br /&gt;
&lt;br /&gt;
==Static code checks==&lt;br /&gt;
Madagascar contains the beginning of an implementation of static code checks for security vulnerabilities and coding mistakes with [http://www.splint.org/ Splint]. This is visible in the code through the presence of comments like &amp;lt;tt&amp;gt;/*@out@*/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/*@null@*/&amp;lt;/tt&amp;gt;, which instruct Splint about the intent of different variables and function return values. Future plans include using also dynamic checking by [http://valgrind.org/ Valgrind] or IBM&#039;s [http://www-306.ibm.com/software/awdtools/purify/ Rational Purify]. Madagascar code metrics are [http://www.ohloh.net/p/m8r/analyses/latest assessed periodically by Ohloh].&lt;br /&gt;
&lt;br /&gt;
==Maintaining the maintenance tools==&lt;br /&gt;
Please document scripts used to maintain the Madagascar codebase, and save them in &amp;lt;tt&amp;gt;RSFSRC/admin&amp;lt;/tt&amp;gt;. Cleanup procedures may need to be repeated in the future, as authors are human and can make the same mistakes again.&lt;br /&gt;
&lt;br /&gt;
==Information flow map==&lt;br /&gt;
The vector graphics original of this map in [http://en.wikipedia.org/wiki/Dia_(software) Dia] format is available upon request through the rsf-devel mailing list.&lt;br /&gt;
[[Image:M8rmap.png]]&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
==Dual licensing Madagascar code==&lt;br /&gt;
When in a contractual work relationship, you may find it handy to reuse some of your own existing public code for which you own the copyright. This may also apply if you are doing contract work for a client on behalf of your employer, who owns the copyright.&lt;br /&gt;
&lt;br /&gt;
If your code does not have any GPL-ed dependencies, and the copyright owner agrees to releasing the code under a different license than the GPL, then you are free to go ahead and do it. However, make sure that in every file you state:&lt;br /&gt;
* who is the copyright owner,&lt;br /&gt;
* what are the terms of the proprietary license that it is being released under,&lt;br /&gt;
* that the code has already been licensed to the public under the GNU GPL prior to this as part of the Madagascar package&lt;br /&gt;
It is important to specify all these items, lest years later, someone in your client&#039;s company finds the code, realizes that similar code is part of Madagascar, and wrongly believes that the copyright belonged to his company, and that you infringed it by releasing the code under the GPL.&lt;br /&gt;
&lt;br /&gt;
Make sure that proper copyright and licensing statements are in place in case of dual licensing, even if you are on very good terms with your client, and are certain that they will not falsely accuse you of wrongdoing. Companies get acquired, employees and even owners leave companies, policies and business strategies change, and old contracts, licenses and legal documents get discarded or lost in a mass of old junk. Each source code file should contain all the relevant copyright and licensing information.&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Manual&amp;diff=2004</id>
		<title>Manual</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Manual&amp;diff=2004"/>
		<updated>2011-08-13T01:30:01Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Community */ New Google Groups&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_8418493_XS.jpg|right|]]&lt;br /&gt;
As the number of pages on the Wiki grows, the navbar starts becoming insufficient for proper organization of all documentation. A top-down view of all materials about Madagascar is also useful for determining whether gaps in coverage exist. This page will stay in the Sandbox for a long while -- until all gaps have been filled.&lt;br /&gt;
&lt;br /&gt;
Ideally the manual will only consist of either links to wiki pages, or own content. &amp;quot;Forking&amp;quot;, i.e. creating a modified copy of a page especially for the manual, invariably ends up with one version getting out of synch.&lt;br /&gt;
&lt;br /&gt;
=About Madagascar=&lt;br /&gt;
==Introduction==&lt;br /&gt;
[[Main Page]] of the wiki, and the [[Package overview]].&lt;br /&gt;
&lt;br /&gt;
==For people who do not read manuals==&lt;br /&gt;
Point them to [[Download]], [[Installation|Short Install Guide]], and the [[Revisiting SEP tour with Madagascar and SCons|SEPlib Tour Revisited]].&lt;br /&gt;
&lt;br /&gt;
==Why use Madagascar?==&lt;br /&gt;
An articulate description of the reasons on the [[Why Madagascar]] page. Have some spectacular pictures obtained with algorithms that are not present in other packages. Describe algorithms/tools unavailable in other open-source geophysical data analysis packages.&lt;br /&gt;
&lt;br /&gt;
==Community==&lt;br /&gt;
A description of the current Madagascar community, with the map of downloads and an estimate of the number of installs, who are the biggest users, outstanding research results obtained with Madagascar, etc. Links to the [http://reproducibility.org/rsflog/ blog], [https://lists.sourceforge.net/lists/listinfo/rsf-user user mailing list], [https://lists.sourceforge.net/lists/listinfo/rsf-devel developer mailing list]. Mention of the Google Groups mirrors for [https://groups.google.com/forum/#!forum/osdeve_mirror_geophysics_rsf-user rsf-user] and [https://groups.google.com/forum/#!forum/osdeve_mirror_geophysics_rsf-devel rsf-devel] Also mention the [http://sourceforge.net/tracker/?group_id=162909&amp;amp;atid=825645 bug tracker] and [http://sourceforge.net/tracker/?group_id=162909&amp;amp;atid=825648 feature request tracker], encouraging the community to use them more. Mention [http://sourceforge.net/forum/?group_id=162909 forums] as an alternative for those who want to ask questions or conduct discussions without subscribing to a mailing list.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
A history of Madagascar, with the SEPlib/SU part of the [[Introduction_to_madagascar#Alternatives|&amp;quot;Alternatives&amp;quot; section of the Introduction]], and mentions of landmark events (short descriptions where necessary): &lt;br /&gt;
* 2003: Work started by Sergey Fomel&lt;br /&gt;
* 2004-08 (?): made available to selected alpha users&lt;br /&gt;
* 2005-02-16: RSF Blog started&lt;br /&gt;
* 2006-03-17: Registered on Sourceforge&lt;br /&gt;
* 2006-04-19: [http://www.m8r.info/rsflog/index.php?/archives/67-Madagascar.html Name change from RSF to Madagascar]&lt;br /&gt;
* 2006-06-11: Public launch at the Open Source E&amp;amp;P Software EAGE Workshop (Vienna)&lt;br /&gt;
* 2006-06-18: [http://www.m8r.info/rsflog/index.php?/archives/74-Mailing-lists-and-madagascar-0.9.1.html First stable version (0.9.1). Mailing lists created]&lt;br /&gt;
* 2006-07-23: [http://www.m8r.info/rsflog/index.php?/archives/86-New-madagascar-logo.html Madagascar logo created by Scott Rodgers (BEG)]&lt;br /&gt;
* 2007-04-27: Release 0.9.4&lt;br /&gt;
* 2007-11-10: Release 0.9.5&lt;br /&gt;
* 2008-06-14: Release 0.9.6&lt;br /&gt;
* 2009-01-03: Release 0.9.7&lt;br /&gt;
* 2009-08-01: Release 0.9.8&lt;br /&gt;
* 2010-05-02: Release 0.9.9&lt;br /&gt;
* 2010-07-23: Release 1.0&lt;br /&gt;
* For details on releases after 1.0, see [[Release Notes]]&lt;br /&gt;
&lt;br /&gt;
A link to the appendix containing the content of the [[Conferences]] and [[Publications]] pages.&lt;br /&gt;
&lt;br /&gt;
=Downloading and installing Madagascar=&lt;br /&gt;
==Download==&lt;br /&gt;
[[Download]]&lt;br /&gt;
==Install==&lt;br /&gt;
# [[Installation|Short installation guide]]&lt;br /&gt;
# [[Advanced Installation|Advanced installation guide]]&lt;br /&gt;
==Licensing and export regulations==&lt;br /&gt;
* Explanation and text of the GPL 2+&lt;br /&gt;
* [[US export control]]&lt;br /&gt;
&lt;br /&gt;
=Using Madagascar=&lt;br /&gt;
==The lightning-quick tour==&lt;br /&gt;
The [[Revisiting SEP tour with Madagascar and SCons|revisited SEP Tour]]&lt;br /&gt;
&lt;br /&gt;
==The Madagascar file formats==&lt;br /&gt;
===The Regularly Sampled Format (RSF)===&lt;br /&gt;
The current [[Guide_to_RSF_file_format|Guide to RSF file format]]&lt;br /&gt;
===Handling irregularly sampled data===&lt;br /&gt;
Explain the principle of the current method (sfheadermath/sfheaderwindow used on the trace header block output by su/segyread)&lt;br /&gt;
===Importing and exporting data from and to SEG-Y and SU===&lt;br /&gt;
sfsegyread and sfsuread, with examples&lt;br /&gt;
&lt;br /&gt;
===Importing and exporting data from and to raster images===&lt;br /&gt;
[[Raster image I/O]]&lt;br /&gt;
===Visualizing data and exporting figures with vplot===&lt;br /&gt;
* Explanation of vplot format&lt;br /&gt;
* Preempting display aliasing in raster plots with &amp;lt;tt&amp;gt;sfprep4plot&amp;lt;/tt&amp;gt;&lt;br /&gt;
* How to create vplot images with sfgraph, sfgrey, sfdots, etc. [[Common pen parameters]]&lt;br /&gt;
* How to display vplot images with sfpen. How it defaults to &amp;lt;tt&amp;gt;oglpen&amp;lt;/tt&amp;gt; on systems that support OpenGL, and &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; on systems that do not support it, but have X Windows.&lt;br /&gt;
* How to convert vplot images to other formats with &amp;lt;tt&amp;gt;vpconvert&amp;lt;/tt&amp;gt;. This tool can work on a single plot, i.e.: &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
vpconvert file.vpl file.jpg&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
or an entire collection of files:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
vpconvert format=tiff Fig/*.vpl&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;vpconvert&amp;lt;/tt&amp;gt; program can export to and from a multitude of file formats: avi, eps, gif, jpg, mpeg, pdf, png, ppm, ps, svg, and tif, and is the recommended vpl import and export tool. Older single-purpose utilities (vplot2gif and vplot2avi) are still available.&lt;br /&gt;
&lt;br /&gt;
===Visualizing data and exporting figures with GLE===&lt;br /&gt;
[[Graphics with GLE]]&lt;br /&gt;
&lt;br /&gt;
===Visualizing data and exporting figures with gnuplot===&lt;br /&gt;
[[Graphics with gnuplot]]&lt;br /&gt;
===Visualizing data and exporting figures with PLplot===&lt;br /&gt;
[http://plplot.sourceforge.net/examples.php PLplot] is a device-independent vector-plotting library. Their concept is very similar to that of vplot, but instead&lt;br /&gt;
of separated device-dependent pens (like xtpen or pspen) they use loadable &amp;quot;drivers&amp;quot; (organized as shared objects and connected to a plotting programs in a plugin fashion). They have an extensive high-level interface for different types of plots. &lt;br /&gt;
&lt;br /&gt;
A sample Madagascar program which utilizes PLplot&#039;s surface rendering capabilities is [[Guide_to_madagascar_programs#Plotting_programs_.28development.29 | sfplsurf]].&lt;br /&gt;
&lt;br /&gt;
==Calling existing Madagascar programs==&lt;br /&gt;
===Finding out what program you need===&lt;br /&gt;
# [http://reproducibility.org/rsflog/index.php?/archives/128-How-do-I-find-programs-in-madagascar.html sfdoc -k]&lt;br /&gt;
# [[Task-centric program list]] and all its subordinate nodes&lt;br /&gt;
# Collection of 2-3 page reproducible papers -- &amp;quot;How to do raytracing in Madagascar&amp;quot;; &amp;quot;How to do modeling in Madagascar&amp;quot;; etc&lt;br /&gt;
# [[SU to m8r dictionary]]&lt;br /&gt;
# [[SEPlib to m8r dictionary]]&lt;br /&gt;
# Other such dictionaries, for free or proprietary seismic processing packages. Such dictionaries are also useful because they will highlight algorithms/utilities present in such packages but missing from m8r.&lt;br /&gt;
&lt;br /&gt;
This chapter is now just a sketch, should get quite big. Users approach tools in a task-centric fashion, i.e. Q1:&amp;quot;how do I do X with Madagascar?&amp;quot;, A1:&amp;quot;With feature Y&amp;quot;; Q2: &amp;quot;How do I use feature Y to this end?&amp;quot; M8r is very good at answering Q2, but people ask Q1 first. Many of the reproducible papers included so far contain cutting-edge research. Users learning how to use Madagascar need to start with something much more simple, where they do not have to focus on understanding research on top of understanding software.&lt;br /&gt;
&lt;br /&gt;
===Learning how to use a given program===&lt;br /&gt;
# Command-line self-doc&lt;br /&gt;
# Local html self-doc (&amp;lt;tt&amp;gt;$RSFROOT/doc/index.html&amp;lt;/tt&amp;gt;). Contains all programs installed on the user&#039;s machine and only those programs.&lt;br /&gt;
# [http://reproducibility.org/RSF/ Online self-doc]&lt;br /&gt;
# The wiki [[Guide_to_madagascar_programs|Guide to Programs]].&lt;br /&gt;
# Series of dedicated reproducible papers that present the theory behind specific geophysical programs and demonstrate it with various types of inputs and combination of parameters, like [http://www.reproducibility.org/RSF/book/sep/fkamo/paper_html/paper.html this paper] does for SEPlib&#039;s AMO program.&lt;br /&gt;
# Combining together multiple programs -- the reproducible papers; pointer to relevant section of the manual (&amp;quot;Exploring reproducible papers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==What is reproducibility==&lt;br /&gt;
The whole [[Reproducibility]] page, combined with Section 1 from [[Reproducible computational experiments using SCons]]&lt;br /&gt;
&lt;br /&gt;
==Exploring existing reproducible papers==&lt;br /&gt;
===Papers and books included in the Madagascar distribution===&lt;br /&gt;
[[Reproducible Documents]] and more.&lt;br /&gt;
&lt;br /&gt;
===How to reproduce specific figures in existing papers===&lt;br /&gt;
A frequently encountered case is when a researcher wants to reproduce only one or several figures from an entire paper, but not the entire paper. This can happen because on that system LaTeX dependencies of Madagascar are missing or not working properly, or simply because the researcher is interested only in that result.&lt;br /&gt;
# &#039;&#039;&#039;Finding the paper directory:&#039;&#039;&#039; If the interesting article has been found by browsing/hyperlink to [[Reproducible Documents]], then the reproducibility package corresponding to &amp;lt;pre&amp;gt;http://www.reproducibility.org/RSF/book/&amp;amp;lt;bookname&amp;amp;gt;/&amp;amp;lt;papername&amp;amp;gt;/paper_html/&amp;lt;/pre&amp;gt; can be found in &amp;lt;pre&amp;gt;RSFSRC/book/&amp;amp;lt;bookname&amp;amp;gt;/&amp;amp;lt;papername&amp;amp;gt;/&amp;lt;/pre&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Finding result names:&#039;&#039;&#039; Use the html version of the paper, or grep in all &amp;lt;tt&amp;gt;.tex&amp;lt;/tt&amp;gt; files in the directory for a text string that occurs in the figure legend. Multiple-panel figures may have individual names for each panel. [Note: In pdf versions obtained with scons pdf in paper directory, neither the book name nor paper directory name nor figure names are given. LaTeX options to have figure names as well as a Geophysics-style header/footer with more details on the first page may be in order]&lt;br /&gt;
# &#039;&#039;&#039;Finding where to launch the re-build&#039;&#039;&#039;: In some cases, rules for creating a result are specified in SConstruct files in subdirectories of the main paper directory. If step 4 fails in the main paper directory, then you will have to find where the figure is built. Because result names may be generated automatically, a simple grep may not be enough and you may need to read the SConstruct and python modules imported by it to figure out if the result is generated there.&lt;br /&gt;
# &#039;&#039;&#039;Re-build&#039;&#039;&#039; and display the figure by typing &amp;lt;tt&amp;gt;scons resultname.view&amp;lt;/tt&amp;gt; in the appropriate directory.&lt;br /&gt;
&lt;br /&gt;
SConstructs containing a &amp;lt;tt&amp;gt;Fetch&amp;lt;/tt&amp;gt; instruction will attempt to download public-domain input data from a communal server when the &amp;quot;scons&amp;quot; command is run. A fast internet connection is necessary in this case.&lt;br /&gt;
&lt;br /&gt;
===How to reproduce entire papers using stored figures===&lt;br /&gt;
# See the previous section for how to find the paper directory&lt;br /&gt;
# Pointer to how to download stored figures ([[Download#Reproducible figures]])&lt;br /&gt;
*&amp;lt;tt&amp;gt;scons pdf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;scons read&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Troubleshooting:&lt;br /&gt;
* In case of failure with this kind of messages (details here), you miss TeX system dependencies. Install a TeX system. [http://www.tug.org/texlive/ Tex Live] should have it all. Note: It&#039;s a 1 Gb download. Too large for many individual users to bother with it and for most IT departments of companies to review for security. We should implement individual dependency checking, like we do in the installation. &lt;br /&gt;
* In case of failure with &amp;lt;tt&amp;gt;LaTeX Error: File `geophysics.cls&#039; not found&amp;lt;/tt&amp;gt; you have LaTeX, but you are missing [[SEGTeX]]&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons pdf&amp;lt;/tt&amp;gt; in the paper directory requires pdf figures already in place in order to work, run &amp;lt;tt&amp;gt;sftour scons lock&amp;lt;/tt&amp;gt; (?).&lt;br /&gt;
&lt;br /&gt;
===How to reproduce entire papers and all their figures===&lt;br /&gt;
# See an earlier section for how to find the paper directory&lt;br /&gt;
# The relevant SCons command (&amp;lt;tt&amp;gt;scons lock&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;sftour scons lock&amp;lt;/tt&amp;gt;, as in [[Download#Reproducible figures]] to force reproducing the figures in the paper even when the reference figures repository is present&lt;br /&gt;
&lt;br /&gt;
Tell the user to expect conditional reproducibility: If Matlab is not present, rsftex will not try to build the figures but will use the stored PDF files (same goes for Mathematica, xfig, etc.)&lt;br /&gt;
&lt;br /&gt;
===How to reproduce whole books===&lt;br /&gt;
The [http://sourceforge.net/mailarchive/forum.php?thread_name=20061222142849.9688.qmail%40web34215.mail.mud.yahoo.com&amp;amp;forum_name=rsf-user 2006-12-22 rsf-user thread], [http://reproducibility.org/rsflog/index.php?/archives/142-Assembling-reports-from-papers.html the 2007-04-08 blog entry] and more.&lt;br /&gt;
&lt;br /&gt;
From Jim&#039;s 2009-03-7 rsf-devel message:&lt;br /&gt;
Here is a way to generate all the targets in the subdirectories of $RSFSRC/book/geostats/spatial_stats:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
cd $RSFSRC/book/geostats/spatial_stats&lt;br /&gt;
sftour scons&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
That works pretty nice.  It generates all the targets in each of the 4 subdirectories of book/geostats/spatial_stats.&lt;br /&gt;
&lt;br /&gt;
Now suppose I want to capture the output and errors in a log file (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour scons &amp;gt;&amp;amp; scons.log&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
That&#039;s nice, except all the output goes into one log file in book/geostats/spatial_stats.  Suppose I want 4 separate log files, one in each of the subdirectories.  This will do the trick:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The quotes make the entire string go to sftour as the command to run in each directory, instead of just &#039;scons&#039;.&lt;br /&gt;
&lt;br /&gt;
So far so good.  Now suppose I want to go up one directory level and do the process recursively:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
cd $RSFSRC/book/geostats&lt;br /&gt;
sftour sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Well, that runs scons in each of the book/geostats/*/* directories, but it only makes 3 log files in the 3 subdirectories of book/geostats, not 14 log files in the 14 book/geostats/*/* directories.  I can get 14 separate log files like this:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour &amp;quot;sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&amp;quot;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
That does what I want.  Now suppose I want to go up one more level to $RSFSRC/book and run the process recursively three levels deep:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour sftour &amp;quot;sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&amp;quot;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This works, but it doesn&#039;t put the log files in the bottom level, it puts them one level up.  I can&#039;t fix it the same way I did before because I&#039;ve run out of quotes :-)  Here is one way to do it (tcsh):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
foreach i (*)&lt;br /&gt;
    if ( -d $i) then&lt;br /&gt;
        echo ++++++ $i&lt;br /&gt;
        cd $i&lt;br /&gt;
        sftour &amp;quot;sftour &#039;/usr/bin/time -p scons &amp;gt;&amp;amp; scons.log&#039;&amp;quot;&lt;br /&gt;
        cd ..&lt;br /&gt;
    endif&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From Sergey&#039;s 2009-03-10 rsf-devel message: A more elegant solution is&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour sftour scons &amp;gt;&amp;amp; ../../%/%/scons.log&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Writing a LaTeX paper in the Madagascar framework==&lt;br /&gt;
Follows the natural progression of learning of somebody who may even not know LaTeX, let alone SCons. &lt;br /&gt;
# A paper with no figures. &lt;br /&gt;
# A paper with NR-only figures&lt;br /&gt;
==Creating a reproducible paper==&lt;br /&gt;
Sections 2 and 3 from [[Reproducible computational experiments using SCons]]. Also, mention the &amp;quot;SCons macros&amp;quot; in &amp;lt;tt&amp;gt;book/Recipes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Publications included in Madagascar&#039;s book directories are tested periodically. Those publications that fail the tests and are not easily repaired are moved to &amp;lt;tt&amp;gt;book/Grave&amp;lt;/tt&amp;gt;, with a note on how the tests failed and why the problems could not be fixed.&lt;br /&gt;
==Data-conditional reproducibility==&lt;br /&gt;
Due to seismic data licensing terms, an author may find it possible to make public everything that is needed to make a publication reproducible, except for the data. In such conditions, the paper is still acceptable for inclusion in the Madagascar collection. To indicate that certain datasets are private, the relevant &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files should use &amp;lt;tt&amp;gt;Fetch(...,local=1)&amp;lt;/tt&amp;gt; or tt&amp;gt;Fetch(...,server=private.server)&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;private.server&amp;lt;/tt&amp;gt; is a password-protected private server. Affected  vplot figures should be uploaded to the [[Download#Reproducible figures | figure repository]]. Reproducibility testing will be skipped for the affected figures, but the html and pdf versions of the publications will still be created.&lt;br /&gt;
&lt;br /&gt;
The usage of public seismic datasets, such as those at http://software.seg.org/, is strongly encouraged.&lt;br /&gt;
&lt;br /&gt;
==Creating a reproducible book==&lt;br /&gt;
&lt;br /&gt;
=Developing in Madagascar=&lt;br /&gt;
==Writing your own programs==&lt;br /&gt;
===Introduction to the Madagascar API===&lt;br /&gt;
# The existing [[Guide_to_madagascar_API|data clipping API demo]]&lt;br /&gt;
# A more complex [[Guide_to_programming_with_madagascar|finite differences API demo]] &amp;amp;ndash; add Python, F77 and Matlab APIs to it&lt;br /&gt;
&lt;br /&gt;
===How to add your program===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#How_to_add_your_program|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===How to document your program===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#How_to_document_your_program|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===Style guide===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#Style_guide|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===How to test your program===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#How_to_test_your_program|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===How to parallelize your programs===&lt;br /&gt;
The [[Parallel Computing]] page.&lt;br /&gt;
&lt;br /&gt;
===Tips and tricks===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#Tips_and_tricks|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===Madagascar library reference===&lt;br /&gt;
* [[Library Reference]]&lt;br /&gt;
* The [http://m8r.info/rsf_epydoc/ Python API documentation]&lt;br /&gt;
* The [http://m8r.info/RSF/book/rsf/manual/manual_html/ Programming Reference Manual]&lt;br /&gt;
&lt;br /&gt;
==Adding programs to the central repository==&lt;br /&gt;
==Framework development and maintenance==&lt;br /&gt;
Description of m8r&#039;s inner works for those who want to help improve and maintain Madagascar. [[Maintenance guide]] and perhaps other stuff.&lt;br /&gt;
==Graphics development with vplot==&lt;br /&gt;
[[Graphics development with vplot]]&lt;br /&gt;
==Packaging madagascar==&lt;br /&gt;
[[Packaging madagascar]]&lt;br /&gt;
&lt;br /&gt;
=Datasets distributed with Madagascar=&lt;br /&gt;
* Description of datasets &amp;amp;ndash; pictures of the velocity model, of sample gathers, zero-offset sections, migrated image.&lt;br /&gt;
* Comment on which are the main problems they illustrate (internal multiples? overturning waves? etc). Algorithm used for generating them, references to published literature describing the datasets&lt;br /&gt;
* Command line options for correctly reading them from the storage format (SEG-Y, most probably) into RSF&lt;br /&gt;
* In general, expand the [[Reproducible_Documents#Madagascar_Datasets | datasets section of Reproducible Documents page]] to include other datasets&lt;br /&gt;
&lt;br /&gt;
=Other open-source data analysis packages=&lt;br /&gt;
==Geophysical software==&lt;br /&gt;
[[Other open-source geophysical packages]]. Briefly discuss each of them. Mention &amp;quot;dictionaries&amp;quot; from them to m8r where available (should attempt to have dictionaries for all of them)&lt;br /&gt;
&lt;br /&gt;
==Other tools==&lt;br /&gt;
There are many other useful open-source or public domain software tools in the domain of applied mathematics, that can be used complementary to Madagascar. A few common examples, in alphabetical order, are:&lt;br /&gt;
&lt;br /&gt;
* [http://www.alglib.net/ ALGLIB]: a highly portable numerical analysis and data processing library;&lt;br /&gt;
* [http://www.caam.rice.edu/software/ARPACK/ ARPACK] (&amp;quot;The ARnoldi PACKage&amp;quot;): a library written in FORTRAN 77 for solving large-scale eigenvalue problems;&lt;br /&gt;
* [http://math-atlas.sourceforge.net/ ATLAS] (&amp;quot;Automatically Tuned Linear Algebra Software&amp;quot;): a linear algebra library, implementing the [http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms BLAS] APIs for C and Fortran77;&lt;br /&gt;
* [http://www.oonumerics.org/blitz/ Blitz++]: a C++ class library for scientific computing which provides performance on par with Fortran 77/90;&lt;br /&gt;
* [http://www.dune-project.org/ DUNE] (&amp;quot;Distributed and Unified Numerics Environment&amp;quot;): a modular toolbox for solving partial differential equations with grid-based methods. It supports the easy implementation of methods like Finite Elements, Finite Volumes, and also Finite Differences. &lt;br /&gt;
* [http://fftw.org/ FFTW] (&amp;quot;The Fastest Fourier Transform in the West&amp;quot;): Hardware-adaptive FFT libraries;&lt;br /&gt;
* [http://www.gnu.org/software/gsl/ GNU Scientific Library]: a C library for numerical calculations in many branches of applied mathematics and science;&lt;br /&gt;
* [http://gts.sourceforge.net/index.html GNU Triangulated Surface Library]: a library providing a set of useful functions to deal with 3D surfaces meshed with interconnected triangles;&lt;br /&gt;
* [http://www.netlib.org/lapack/ LAPACK] (&amp;quot;The Linear Algebra PACKage&amp;quot;): a collection of routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/MINPACK MINPACK]: a library of FORTRAN subroutines for the solving of systems of nonlinear equations, or the least squares minimization of the residual of a set of linear or nonlinear equations;&lt;br /&gt;
* [http://www.mcs.anl.gov/petsc/petsc-2/ PETSc] (&amp;quot;the Portable, Extensible Toolkit for Scientific computation&amp;quot;): A set of serial and parallel, linear and nonlinear, solvers for large-scale, sparse linear and nonlinear systems of equations;&lt;br /&gt;
* [http://www.scipy.org/ SciPY] (&amp;quot;Scientific Python&amp;quot;): a toolbox for scientific computing in Python;&lt;br /&gt;
* [http://www.boost.org/doc/libs/1_39_0/libs/numeric/ublas/doc/index.htm uBLAS]: a C++ template class library that provides BLAS level 1, 2, 3 functionality for dense, packed and sparse matrices.&lt;br /&gt;
&lt;br /&gt;
Most [http://en.wikipedia.org/ Wikipedia] pages of the above libraries are valuable resources, as is Wikipedia&#039;s [http://en.wikipedia.org/wiki/List_of_numerical_analysis_software list of numerical analysis software]. Other libraries and standalone programs are available through the [http://www.netlib.org/ Netlib repository] and indexed by the [http://gams.nist.gov/ Guide to Available Mathematical Software]. The U.S. DOE&#039;s [http://acts.nersc.gov/ ACTS Collection] is another valuable repository.&lt;br /&gt;
&lt;br /&gt;
==Madagascar in conferences and publications==&lt;br /&gt;
The content of the [[Conferences]] and [[Publications]] pages. A mention about the reproducible documents that are listed in the &amp;quot;Papers and books included in the Madagascar distribution&amp;quot; sections.&lt;br /&gt;
==Madagascar project system administrator&#039;s guide==&lt;br /&gt;
[[Mediawiki installation, customization and operation]]&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Raster_image_I/O&amp;diff=2003</id>
		<title>Raster image I/O</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Raster_image_I/O&amp;diff=2003"/>
		<updated>2011-08-13T01:16:34Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Converting RSF 2-D data to raster images */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Converting raster images to RSF files==&lt;br /&gt;
One option is &amp;lt;tt&amp;gt;sftif2byte&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sfjpg2byte&amp;lt;/tt&amp;gt;. It requires the TIFF or JPEG library, respectively, to be present at the compilation time.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; lena.tif sftif2byte | sfdd type=float &amp;gt; lena.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; lena.jpg sfjpg2byte | sfdd type=float &amp;gt; lena.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Another option is to use the &amp;lt;tt&amp;gt;convert&amp;lt;/tt&amp;gt; utility from [http://www.imagemagick.org ImageMagick]. For a grayscale image:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; lena.jpg convert - lena.gray&lt;br /&gt;
echo in=lena.gray data_format=native_uchar n1=512 n2=512 | sfdd type=float &amp;gt; lena.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
or, for a color image:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; lena.jpg convert - lena.rgb&lt;br /&gt;
&lt;br /&gt;
echo in=lena.rgb data_format=native_uchar n1=3 n2=512 n3=512 | sfdd type=float &amp;gt; lena.rsf&lt;br /&gt;
&lt;br /&gt;
# Red component:&lt;br /&gt;
&amp;lt; lena_rgb.rsf sfwindow n1=1 f1=0 &amp;gt; lena_red.rsf&lt;br /&gt;
# Green:&lt;br /&gt;
&amp;lt; lena_rgb.rsf sfwindow n1=1 f1=1 &amp;gt; lena_green.rsf&lt;br /&gt;
# Blue:&lt;br /&gt;
&amp;lt; lena_rgb.rsf sfwindow n1=1 f1=2 &amp;gt; lena_blue.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Converting RSF 2-D data to raster images==&lt;br /&gt;
If Madagascar has been compiled with TIFF support, &amp;lt;tt&amp;gt;sfbyte2tif&amp;lt;/tt&amp;gt; can be used:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; model.rsf sfbyte | sfbyte2tif &amp;gt; model.tif&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If Madagascar has been compiled with JPEG support, &amp;lt;tt&amp;gt;sfbyte2jpg&amp;lt;/tt&amp;gt; can be used:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; model.rsf sfbyte | sfbyte2jpg &amp;gt; model.jpg&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Then, another program can be used to convert the JPEG file to another format.&lt;br /&gt;
If [http://www.imagemagick.org ImageMagick] is present, it can be used to convert a RSF binary to almost any image format. In a SConstruct, the workflow would look like:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;data.gray&#039;,&#039;data&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    transp |  # Make data in row-major order&lt;br /&gt;
    byte gainpanell=all allpos=y |  # Convert data to byte representation&lt;br /&gt;
    disfil col=1 number=n format=&amp;quot;%02X&amp;quot; |  # Dump data in one column in ASCII-hex&lt;br /&gt;
    xxd -r -p  # Read ASCII output and convert it to binary form&lt;br /&gt;
    &#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;data.png&#039;,&#039;data.gray&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    convert -size %dx%d -depth 8 ${SOURCES[0]} ${TARGETS[0]}  # Run ImageMagick&lt;br /&gt;
    &#039;&#039;&#039; % (n2, n1), stdin=0, stdout=0)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To output to another format, just change the extension in the last &amp;lt;tt&amp;gt;Flow()&amp;lt;/tt&amp;gt; from .png to .gif or .jpg, for example. Create the output simply by running: &amp;lt;tt&amp;gt;scons data.png&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=2002</id>
		<title>Contributing new programs to Madagascar</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Contributing_new_programs_to_Madagascar&amp;diff=2002"/>
		<updated>2011-08-13T01:14:43Z</updated>

		<summary type="html">&lt;p&gt;Nick: Dual licensing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you want to share your code with other Madagascar users:   &lt;br /&gt;
# Follow the guide on [[Adding new programs to Madagascar]].&lt;br /&gt;
# If your employer holds the copyright for your software, obtain a permission to distribute under a [http://www.gnu.org/copyleft/gpl.html GPL license] and  place a copyright and GPL license notice in each file with code. &lt;br /&gt;
# [http://sourceforge.net/account/registration/ Register at SourceForge].&lt;br /&gt;
# Find out who the project administrators are (Look for &amp;quot;Project Admins&amp;quot; on [http://sourceforge.net/projects/rsf/ this page]) and pass your SourceForge user name to one of them.&lt;br /&gt;
# Upload your directory to the repository using &amp;lt;tt&amp;gt;[http://svnbook.red-bean.com/en/1.0/re01.html svn add]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[http://svnbook.red-bean.com/en/1.1/re06.html svn commit]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Make sure to add reproducible examples of using your program under the &amp;lt;tt&amp;gt;RSFSRC/book&amp;lt;/tt&amp;gt; tree. Create new directories if necessary and commit them to the repository. As a rule, programs without examples are not included in the release version.&lt;br /&gt;
&lt;br /&gt;
Some additional useful information is included below.&lt;br /&gt;
&lt;br /&gt;
==Repository procedure suggestions==&lt;br /&gt;
Please try to:&lt;br /&gt;
* Do [http://en.wikipedia.org/wiki/Atomic_commit atomic commits].&lt;br /&gt;
* Use &amp;lt;tt&amp;gt;svn commit -m &amp;quot;your message here&amp;quot;&amp;lt;/tt&amp;gt; to let others know what changed.&lt;br /&gt;
** Alternatively, set the &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;SVN_EDITOR&amp;lt;/tt&amp;gt; environmental variables to your favorite editor and edit your message there.&lt;br /&gt;
* If you plan to do large-scale substantive changes, create a Subversion [http://en.wikipedia.org/wiki/Branching_(software) branch] by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
svn copy https://rsf.svn.sourceforge.net/svnroot/rsf/trunk https://rsf.svn.sourceforge.net/svnroot/rsf/yourbranchname&lt;br /&gt;
svn co https://rsf.svn.sourceforge.net/svnroot/rsf/yourbranchname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For coding style suggestions, please see [[Adding_new_programs_to_Madagascar#Style_guide | the &amp;quot;Adding new programs&amp;quot; section]]. &lt;br /&gt;
&lt;br /&gt;
==Backward compatibility features==&lt;br /&gt;
If you introduce or notice a feature that is used solely for backwards compatibility with an old version of a dependency, please document it here, so that the feature can be eliminated when the Madagascar community stops supporting that version of that dependency&amp;lt;ref&amp;gt;This could be more elegantly done by using a special string to flag a backwards compatibility comment in the code, then have the documentation builder build this list automatically. This would make it more likely for this page to be kept in synch with the codebase.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Python 2.2 and older===&lt;br /&gt;
* In &amp;lt;tt&amp;gt;framework/rsfdoc.py&amp;lt;/tt&amp;gt;: Everything in the &amp;lt;tt&amp;gt;have_datetime_module=False&amp;lt;/tt&amp;gt; branches&lt;br /&gt;
&lt;br /&gt;
===Python 2.3 and older===&lt;br /&gt;
* In &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt;: Everything in the &amp;lt;tt&amp;gt;have_subprocess=False&amp;lt;/tt&amp;gt; branches&lt;br /&gt;
* In &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt;: See code after comment &amp;quot;For Py 2.4 and up this can be done more elegantly...&amp;quot;&lt;br /&gt;
* In &amp;lt;tt&amp;gt;user/ivlad/ivlad.py&amp;lt;/tt&amp;gt;: Everything in the &amp;lt;tt&amp;gt;have_subprocess=False&amp;lt;/tt&amp;gt; branches&lt;br /&gt;
* The entire &amp;lt;tt&amp;gt;api/python/rsfbak.py&amp;lt;/tt&amp;gt; (also needed on systems which do not have recent versions of numpy &#039;&#039;and&#039;&#039; SWIG)&lt;br /&gt;
===Python 2.4 and older===&lt;br /&gt;
* try (try...except)... finally construct instead of try... except... finally in &amp;lt;tt&amp;gt;framework/rsfdoc.py&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Mitigating missing dependencies==&lt;br /&gt;
The main idea is to attempt to provide [http://en.wikipedia.org/wiki/Graceful_degradation graceful degradation] when facing a missing dependency. Quoting the Wikipedia page on fault-tolerant systems, this &amp;quot;enables a system to continue operating properly in the event of the failure of (or one or more faults within) some of its components. If its operating quality decreases at all, the decrease is proportional to the severity of the failure, as compared to a naively-designed system in which even a small failure can cause total breakdown.&amp;quot;&lt;br /&gt;
===SWIG or numpy===&lt;br /&gt;
Graceful degradation is implemented. Please see the [[Advanced_Installation#Python API | Advanced Installation / Python API]] for an introduction to this issue. The module providing the limited functionality is &amp;lt;tt&amp;gt;api/python/rsfbak.py&amp;lt;/tt&amp;gt;, which emulates header and command-line parameter reading functions from headers from the &amp;quot;official&amp;quot; development kit. When writing a Python program manipulating headers, it may be tempting to write &amp;lt;tt&amp;gt;import rsfbak&amp;lt;/tt&amp;gt; because it is present anyway, but it is not a good idea. Use instead something like:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
try:&lt;br /&gt;
    import rsf&lt;br /&gt;
except: # Python devkit not installed&lt;br /&gt;
    import rsfbak as rsf&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
The reason is that the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; Python module is an interface to the homonymous C library, which ensures a unitary implementation of I/O throughout the package, and it should be used whenever possible. Having programs that do RSF I/O but never uses the official library practically forks the API, which is a Bad Thing. Using the pattern above ensures the alternate partial implementation is permanently synced with the principal implementation.&lt;br /&gt;
&lt;br /&gt;
==Reasons for the existence of certain features==&lt;br /&gt;
===Why pyc files are generated during the install step===&lt;br /&gt;
Python bytecode files, with the pyc extensions, are created during the &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; in order to:&lt;br /&gt;
* Register them in SCons&#039; dependency tree, so that they are removed by &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Avoid a situation in which a user tries to execute a Madagascar Python program, but creating the pyc file during a module import fails because of lack of write access to &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==cfortran.h==&lt;br /&gt;
This source code file provides a machine-independent interface between C procedures, Fortran procedures and global data (more details [http://www-zeus.desy.de/~burow/cfortran/ on the website of its initial author]). It is a dependency of the F77 and F90 APIs, as well as of vplot. It is included in m8r in &amp;lt;tt&amp;gt;api/f90&amp;lt;/tt&amp;gt; with a link in &amp;lt;tt&amp;gt;api/f77&amp;lt;/tt&amp;gt;. Version 4.3 (2002) is still distributed through the website of the original author. Another version (fork?) is [http://root.cern.ch/viewvc/trunk/montecarlo/eg/inc/cfortran.h?view=log maintained at CERN] and distributed in the include directory of the interface to event generators in the Monte Carlo libraries in the [http://cernlib.web.cern.ch/cernlib/ CERN Program Library] (CERNlib). Debian distributes the Free Software part of this package as &amp;lt;tt&amp;gt;cernlib&amp;lt;/tt&amp;gt;. Under Fedora, &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; is included in &amp;lt;tt&amp;gt;cernlib-g77-devel&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cernlib-devel&amp;lt;/tt&amp;gt;, which happily overwrite each other&#039;s files and create copies of &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; in two different locations deeply nested under &amp;lt;tt&amp;gt;/usr/include&amp;lt;/tt&amp;gt;. CERNlib&#039;s Debian maintainer states that [http://people.debian.org/~kmccarty/cernlib/index.html &amp;quot;CERNlib is an ancient mass of mostly Fortran code&amp;quot;] and that [http://people.debian.org/~kmccarty/physics-software-rant.html &amp;quot;Most components of CERNLIB are completely broken on modern 64-bit architectures&amp;quot;], so m8r developers should be aware that CERNlib will probably be superseded at some point in the future by [http://en.wikipedia.org/wiki/ROOT ROOT], with upstream &amp;lt;tt&amp;gt;cfortran.h&amp;lt;/tt&amp;gt; maintenance possibly continuing this way.&lt;br /&gt;
&lt;br /&gt;
==Static code checks==&lt;br /&gt;
Madagascar contains the beginning of an implementation of static code checks for security vulnerabilities and coding mistakes with [http://www.splint.org/ Splint]. This is visible in the code through the presence of comments like &amp;lt;tt&amp;gt;/*@out@*/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/*@null@*/&amp;lt;/tt&amp;gt;, which instruct Splint about the intent of different variables and function return values. Future plans include using also dynamic checking by [http://valgrind.org/ Valgrind] or IBM&#039;s [http://www-306.ibm.com/software/awdtools/purify/ Rational Purify]. Madagascar code metrics are [http://www.ohloh.net/p/m8r/analyses/latest assessed periodically by Ohloh].&lt;br /&gt;
&lt;br /&gt;
==Maintaining the maintenance tools==&lt;br /&gt;
Please document scripts used to maintain the Madagascar codebase, and save them in &amp;lt;tt&amp;gt;RSFSRC/admin&amp;lt;/tt&amp;gt;. Cleanup procedures may need to be repeated in the future, as authors are human and can make the same mistakes again.&lt;br /&gt;
&lt;br /&gt;
==Information flow map==&lt;br /&gt;
The vector graphics original of this map in [http://en.wikipedia.org/wiki/Dia_(software) Dia] format is available upon request through the rsf-devel mailing list.&lt;br /&gt;
[[Image:M8rmap.png]]&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
==Dual licensing Madagascar code==&lt;br /&gt;
When in a contractual work relationship, you may find it handy to reuse some of your own existing public code for which you own the copyright. This may also apply if you are doing contract work for a client on behalf of your employer, who owns the copyright.&lt;br /&gt;
&lt;br /&gt;
If your code does not have any GPL-ed dependencies, and the copyright owner agrees to releasing the code under a different license than the GPL, then you are free to go ahead and do it. However, make sure that in every file you state:&lt;br /&gt;
* who is the copyright owner,&lt;br /&gt;
* what are the terms of the proprietary license that it is being released under,&lt;br /&gt;
* that the code has already been licensed to the public under the GNU GPL prior to this as part of the Madagascar package&lt;br /&gt;
It is important to specify all these items, lest years later, someone in your client&#039;s company finds the code, realizes that similar code is part of Madagascar, and wrongly believes that the copyright belonged to his company, and that you infringed it by releasing the code under the GPL.&lt;br /&gt;
&lt;br /&gt;
Make sure that proper copyright and licensing statements are in place in case of dual licensing, even if you are on very good terms with your client, and are certain that they will not falsely accuse you of wrongdoing. Companies get acquired, employees and even owners leave companies, policies and business strategies change, and old contracts, licenses and legal documents get discarded or lost in a mass of old junk. Each source code file should contain all the relevant copyright and licensing information.&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Mediawiki_installation,_customization_and_operation&amp;diff=1997</id>
		<title>Mediawiki installation, customization and operation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Mediawiki_installation,_customization_and_operation&amp;diff=1997"/>
		<updated>2011-08-12T02:59:11Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Disabling media uploads */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Installation==&lt;br /&gt;
The Madagascar Mediawiki installation consists of:&lt;br /&gt;
* A SQL database back-end, that holds text, images, history and user data&lt;br /&gt;
* A set of PHP scripts, that dynamically generate the HTML pages&lt;br /&gt;
* Auxiliary files uploaded directly to the server&lt;br /&gt;
&lt;br /&gt;
Advanced web hosting providers offer &amp;quot;one-click&amp;quot; installs of Mediawiki, but database migration and PHP customization must still be performed.&lt;br /&gt;
&lt;br /&gt;
==Customization==&lt;br /&gt;
&lt;br /&gt;
===Favicon and logo===&lt;br /&gt;
In &amp;lt;tt&amp;gt;LocalSettings.php&amp;lt;/tt&amp;gt;, set &lt;br /&gt;
&amp;lt;php&amp;gt;&lt;br /&gt;
$wgFavicon = &#039;/wikilocal/style/favicon.png&#039;;&lt;br /&gt;
$wgLogo    = &#039;/wikilocal/style/Madagascar2.png&#039;;&lt;br /&gt;
&amp;lt;/php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Footer===&lt;br /&gt;
To insert the images/links to the Ohloh, Sourceforge and Cafepress, edit &amp;lt;tt&amp;gt;includes/Skin.php&amp;lt;/tt&amp;gt; to replace the default function &amp;lt;tt&amp;gt;getPoweredBy()&amp;lt;/tt&amp;gt; with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;php&amp;gt;&lt;br /&gt;
        function getPoweredBy() {&lt;br /&gt;
                global $wgStylePath;&lt;br /&gt;
                $ohloh = &#039;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://www.ohloh.net/p/348236/widgets/project_thin_badge.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#039;;&lt;br /&gt;
                $sf1=&#039;&amp;lt;a href=&amp;quot;http://sourceforge.net/projects/rsf&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
                $sf2=&#039;&amp;lt;img src=&amp;quot;http://sflogo.sourceforge.net/sflogo.php?group_id=162909&amp;amp;amp;type=13&amp;quot; width=&amp;quot;120&amp;quot; height=&amp;quot;30&amp;quot; border=&amp;quot;0&amp;quot; &#039;;&lt;br /&gt;
                $sf3=&#039;alt=&amp;quot;Get Madagascar at SourceForge.net. Fast, secure and Free Open Source software downloads&amp;quot;/&amp;gt;&amp;lt;/a&amp;gt; &#039;;&lt;br /&gt;
                $sourceforge = $sf1.$sf2.$sf3;&lt;br /&gt;
                $url = htmlspecialchars( &amp;quot;$wgStylePath/common/images/poweredby_mediawiki_88x31.png&amp;quot; );&lt;br /&gt;
                $banner = htmlspecialchars( &amp;quot;/wikilocal/style/store.png&amp;quot; );&lt;br /&gt;
                $store = &#039;&amp;lt;a href=&amp;quot;http://www.cafepress.com/m8r&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;img src=&amp;quot;&#039;.$banner.&#039;&amp;quot; width=&amp;quot;88&amp;quot; height=&amp;quot;31&amp;quot; border=&amp;quot;0&amp;quot; alt=&amp;quot;Madagascar Store&amp;quot; /&amp;gt;&amp;lt;/a&amp;gt; &#039;;&lt;br /&gt;
                $img = $ohloh.$sourceforge.$store.&#039;&amp;lt;a href=&amp;quot;http://www.mediawiki.org/&amp;quot;&amp;gt;&amp;lt;img src=&amp;quot;&#039;.$url.&#039;&amp;quot; alt=&amp;quot;MediaWiki&amp;quot; /&amp;gt;&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
                return $img;&lt;br /&gt;
        }&lt;br /&gt;
&amp;lt;/php&amp;gt;&lt;br /&gt;
===Extensions===&lt;br /&gt;
These are installed in the &amp;lt;tt&amp;gt;extensions&amp;lt;/tt&amp;gt; directory. Currently installed extensions are:&lt;br /&gt;
* googleAnalytics&lt;br /&gt;
* Cite&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Extension:ConfirmEdit ConfirmEdit]&lt;br /&gt;
* GeSHi (syntax highlighting)&lt;br /&gt;
* SpamBlacklist&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Extension:VisualMathCaptcha VisualMathCaptcha], installed in conjunction with ConfirmEdit&lt;br /&gt;
* Widgets:&lt;br /&gt;
** Feed (for the RSFlog RSS feed)&lt;br /&gt;
** YouTube (for some on-screen demos and lectures)&lt;br /&gt;
&lt;br /&gt;
==Operation==&lt;br /&gt;
===Backups===&lt;br /&gt;
Backups should cover the wiki installation (SQL backups must be made by proper script, not by simply copying a file!), as well as a static copy of a wiki to be used in case the database is corrupted during file transfer.&lt;br /&gt;
===Defending against spammers and vandals===&lt;br /&gt;
====Allowing only registered users to edit the wiki====&lt;br /&gt;
This is a measure that was deemed necessary after two years of daily undo-and-block warfare against spammers.&lt;br /&gt;
To set it, use in &amp;lt;tt&amp;gt;LocalSettings.php&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;php&amp;gt;&lt;br /&gt;
$wgGroupPermissions[&#039;*&#039;][&#039;edit&#039;] = false;&lt;br /&gt;
$wgGroupPermissions[&#039;*&#039;][&#039;createpage&#039;] = false;&lt;br /&gt;
$wgGroupPermissions[&#039;*&#039;][&#039;createtalk&#039;] = false;&lt;br /&gt;
&amp;lt;/php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Disabling registration of new users====&lt;br /&gt;
This is a temporary measure, to be used as a stopgap against large attacks, until a permanent effective measure has been found.&lt;br /&gt;
====Disallowing users to create new pages====&lt;br /&gt;
Again, a temporary measure. For attacks which are not so heavy as to warrant disabling registration of new users, and in which spammers are weeded out manually. Several hours may pass between verifications of edits, in which a spammer can create many new pages. Works for attacks centered on new page creation. To set this, use &lt;br /&gt;
&amp;lt;php&amp;gt;&lt;br /&gt;
$wgGroupPermissions[&#039;user&#039;][&#039;createpage&#039;] = false;&lt;br /&gt;
&amp;lt;/php&amp;gt;&lt;br /&gt;
in &amp;lt;tt&amp;gt;LocalSettings.php&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
====Disabling media uploads====&lt;br /&gt;
To disable uploads via the web interface, set&lt;br /&gt;
&amp;lt;php&amp;gt;&lt;br /&gt;
$wgEnableUploads = false;&lt;br /&gt;
&amp;lt;/php&amp;gt;&lt;br /&gt;
in &amp;lt;tt&amp;gt;LocalSettings.php&amp;lt;/tt&amp;gt; .&lt;br /&gt;
To upload images from the command line, without using the web interface, use&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
php wiki/maintenance/importImages.php /path/to/dir/with/images extensions&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If file permission problems are encountered, then&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
chmod -R g+w wiki/images&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1996</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1996"/>
		<updated>2011-08-12T00:48:52Z</updated>

		<summary type="html">&lt;p&gt;Nick: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Cluster.jpg|right|frame|[http://www.freedigitalphotos.net/images/view_photog.php?photogid=1152 Image: jscreationzs / FreeDigitalPhotos.net]]]&lt;br /&gt;
Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Unlike the OpenMP or MPI utilities, this has fault tolerance -- in case of a node failing, restarting the job will allow it to complete.&lt;br /&gt;
&lt;br /&gt;
Simply running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. To fully use the potential of &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; for running on a distributed-memory computer, you need to set the environment variables &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;, and to use &amp;lt;tt&amp;gt;split&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;reduce&amp;lt;/tt&amp;gt; arguments in your SConstruct Flow statements where appropriate.&lt;br /&gt;
&lt;br /&gt;
===Setting the environment variables===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; variable holds, for each node, the name or IP address of that node (in a format that can be used by ssh), followed by the number of threads on the node. For example, creating 26 threads and sending them on 4 nodes, using respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs on each of the last two nodes:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; variable holds the sum of the numbers of threads on all nodes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; is not defined, &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; can be used to override the auto-detected number of threads used on the local host. This can be useful in the case of processes using a large amount of memory.&lt;br /&gt;
&lt;br /&gt;
In Beowulf-type clusters in which communication of the processor with the local disk is much faster than with the shared network storage, it is important to set in the shell resource file the temporary file location to a local disk, and the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable to a network-visible location for global collection of results, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The split and reduce options in Flow()===&lt;br /&gt;
The split option specifies the number of the axis to be split and the size of that axis. For an axis 3 of length 1000 on the standard in file, and collection by concatenation:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Concatenation is the default reduction method. The other valid option is &amp;lt;tt&amp;gt;reduce=&#039;add&#039;&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
In flows that are run by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;, but contain both serial and parallel targets, care must be exercised in order to not create bottlenecks, in which tasks are distributed to multiple nodes, but the nodes sit idle while waiting other nodes to finish computing dependencies. Tasks that are not explicitly parallelized will be sped up by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; if they are independent from each other. For example, building Madagascar with &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; instead of scons results in a visible speedup on a multithreaded machine.&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons attempts to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel, especially by overloading the I/O system with identical operations.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===What to expect at runtime===&lt;br /&gt;
SCons will create intermediate input and output slices in the current directory. For example, for&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
Flow(&#039;out&#039;,&#039;inp&#039;,&#039;radon np=100 p0=0 dp=0.01&#039;,split=[3,256])&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
RSF_THREADS=8&lt;br /&gt;
RSF_CLUSTER=&#039;localhost 4 node1.utexas.edu 4&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
the SCons output will look like:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=0 squeeze=n &amp;gt; inp__0.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=42 squeeze=n &amp;gt; inp__1.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; /bin/env &amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=84 squeeze=n &amp;gt; inp__2.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=126 squeeze=n &amp;gt; inp__3.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=168 squeeze=n &amp;gt; inp__4.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; /bin/env &amp;lt; inp.rsf /RSFROOT/bin/sfwindow f3=210 squeeze=n &amp;gt; inp__5.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__0.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__0.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; /bin/env &amp;lt; inp__1.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__1.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__3.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__3.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; &amp;lt; spike__4.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__4.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__2.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__2.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__5.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__5.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; out__0.rsf /RSFROOT/bin/sfcat axis=3 out__1.rsf out__2.rsf out__3.rsf out__4.rsf out__5.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that operations were sent for execution in parallel, but the display is necessarily serial.&lt;br /&gt;
&lt;br /&gt;
Runtime job monitoring can be achieved with &#039;&#039;&#039;sftop&#039;&#039;&#039;. To kill a distributed job, use &#039;&#039;&#039;sfkill&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1994</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1994"/>
		<updated>2011-08-11T03:20:58Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* What to expect at runtime */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Unlike the OpenMP or MPI utilities, this has fault tolerance -- in case of a node failing, restarting the job will allow it to complete.&lt;br /&gt;
&lt;br /&gt;
Simply running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. To fully use the potential of &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; for running on a distributed-memory computer, you need to set the environment variables &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;, and to use &amp;lt;tt&amp;gt;split&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;reduce&amp;lt;/tt&amp;gt; arguments in your SConstruct Flow statements where appropriate.&lt;br /&gt;
&lt;br /&gt;
===Setting the environment variables===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; variable holds, for each node, the name or IP address of that node (in a format that can be used by ssh), followed by the number of threads on the node. For example, creating 26 threads and sending them on 4 nodes, using respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs on each of the last two nodes:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; variable holds the sum of the numbers of threads on all nodes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; is not defined, &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; can be used to override the auto-detected number of threads used on the local host. This can be useful in the case of processes using a large amount of memory.&lt;br /&gt;
&lt;br /&gt;
In Beowulf-type clusters in which communication of the processor with the local disk is much faster than with the shared network storage, it is important to set in the shell resource file the temporary file location to a local disk, and the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable to a network-visible location for global collection of results, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The split and reduce options in Flow()===&lt;br /&gt;
The split option specifies the number of the axis to be split and the size of that axis. For an axis 3 of length 1000 on the standard in file, and collection by concatenation:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Concatenation is the default reduction method. The other valid option is &amp;lt;tt&amp;gt;reduce=&#039;add&#039;&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
In flows that are run by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;, but contain both serial and parallel targets, care must be exercised in order to not create bottlenecks, in which tasks are distributed to multiple nodes, but the nodes sit idle while waiting other nodes to finish computing dependencies. Tasks that are not explicitly parallelized will be sped up by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; if they are independent from each other. For example, building Madagascar with &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; instead of scons results in a visible speedup on a multithreaded machine.&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons attempts to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel, especially by overloading the I/O system with identical operations.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===What to expect at runtime===&lt;br /&gt;
SCons will create intermediate input and output slices in the current directory. For example, for&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
Flow(&#039;out&#039;,&#039;inp&#039;,&#039;radon np=100 p0=0 dp=0.01&#039;,split=[3,256])&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
RSF_THREADS=8&lt;br /&gt;
RSF_CLUSTER=&#039;localhost 4 node1.utexas.edu 4&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
the SCons output will look like:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=0 squeeze=n &amp;gt; inp__0.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=42 squeeze=n &amp;gt; inp__1.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; /bin/env &amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=84 squeeze=n &amp;gt; inp__2.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=126 squeeze=n &amp;gt; inp__3.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp.rsf /RSFROOT/bin/sfwindow n3=42 f3=168 squeeze=n &amp;gt; inp__4.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; /bin/env &amp;lt; inp.rsf /RSFROOT/bin/sfwindow f3=210 squeeze=n &amp;gt; inp__5.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__0.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__0.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; /bin/env &amp;lt; inp__1.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__1.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__3.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__3.rsf&lt;br /&gt;
&lt;br /&gt;
/usr/bin/ssh node1.utexas.edu &amp;quot;cd /home/test ; &amp;lt; spike__4.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__4.rsf &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__2.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__2.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; inp__5.rsf /RSFROOT/bin/sfradon p0=0 np=100 dp=0.01 &amp;gt; out__5.rsf&lt;br /&gt;
&lt;br /&gt;
&amp;lt; out__0.rsf /RSFROOT/bin/sfcat axis=3 out__1.rsf out__2.rsf out__3.rsf out__4.rsf out__5.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that operations were sent for execution in parallel, but the display is necessarily serial.&lt;br /&gt;
&lt;br /&gt;
Runtime job monitoring can be achieved with &#039;&#039;&#039;sftop&#039;&#039;&#039;. To kill a distributed job, use &#039;&#039;&#039;sfkill&#039;&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1993</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1993"/>
		<updated>2011-08-11T03:13:15Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Run */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Unlike the OpenMP or MPI utilities, this has fault tolerance -- in case of a node failing, restarting the job will allow it to complete.&lt;br /&gt;
&lt;br /&gt;
Simply running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. To fully use the potential of &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; for running on a distributed-memory computer, you need to set the environment variables &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;, and to use &amp;lt;tt&amp;gt;split&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;reduce&amp;lt;/tt&amp;gt; arguments in your SConstruct Flow statements where appropriate.&lt;br /&gt;
&lt;br /&gt;
===Setting the environment variables===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; variable holds, for each node, the name or IP address of that node (in a format that can be used by ssh), followed by the number of threads on the node. For example, creating 26 threads and sending them on 4 nodes, using respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs on each of the last two nodes:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; variable holds the sum of the numbers of threads on all nodes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; is not defined, &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; can be used to override the auto-detected number of threads used on the local host. This can be useful in the case of processes using a large amount of memory.&lt;br /&gt;
&lt;br /&gt;
In Beowulf-type clusters in which communication of the processor with the local disk is much faster than with the shared network storage, it is important to set in the shell resource file the temporary file location to a local disk, and the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable to a network-visible location for global collection of results, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The split and reduce options in Flow()===&lt;br /&gt;
The split option specifies the number of the axis to be split and the size of that axis. For an axis 3 of length 1000 on the standard in file, and collection by concatenation:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Concatenation is the default reduction method. The other valid option is &amp;lt;tt&amp;gt;reduce=&#039;add&#039;&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
In flows that are run by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;, but contain both serial and parallel targets, care must be exercised in order to not create bottlenecks, in which tasks are distributed to multiple nodes, but the nodes sit idle while waiting other nodes to finish computing dependencies. Tasks that are not explicitly parallelized will be sped up by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; if they are independent from each other. For example, building Madagascar with &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; instead of scons results in a visible speedup on a multithreaded machine.&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons attempts to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel, especially by overloading the I/O system with identical operations.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===What to expect at runtime===&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1992</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1992"/>
		<updated>2011-08-11T03:11:44Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* pscons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Unlike the OpenMP or MPI utilities, this has fault tolerance -- in case of a node failing, restarting the job will allow it to complete.&lt;br /&gt;
&lt;br /&gt;
Simply running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. To fully use the potential of &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; for running on a distributed-memory computer, you need to set the environment variables &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;, and to use &amp;lt;tt&amp;gt;split&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;reduce&amp;lt;/tt&amp;gt; arguments in your SConstruct Flow statements where appropriate.&lt;br /&gt;
&lt;br /&gt;
===Setting the environment variables===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; variable holds, for each node, the name or IP address of that node (in a format that can be used by ssh), followed by the number of threads on the node. For example, creating 26 threads and sending them on 4 nodes, using respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs on each of the last two nodes:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; variable holds the sum of the numbers of threads on all nodes, i.e.:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; is not defined, &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt; can be used to override the auto-detected number of threads used on the local host. This can be useful in the case of processes using a large amount of memory.&lt;br /&gt;
&lt;br /&gt;
In Beowulf-type clusters in which communication of the processor with the local disk is much faster than with the shared network storage, it is important to set in the shell resource file the temporary file location to a local disk, and the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable to a network-visible location for global collection of results, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The split and reduce options in Flow()===&lt;br /&gt;
The split option specifies the number of the axis to be split and the size of that axis. For an axis 3 of length 1000 on the standard in file, and collection by concatenation:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
Concatenation is the default reduction method. The other valid option is &amp;lt;tt&amp;gt;reduce=&#039;add&#039;&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
In flows that are run by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;, but contain both serial and parallel targets, care must be exercised in order to not create bottlenecks, in which tasks are distributed to multiple nodes, but the nodes sit idle while waiting other nodes to finish computing dependencies. Tasks that are not explicitly parallelized will be sped up by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; if they are independent from each other. For example, building Madagascar with &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; instead of scons results in a visible speedup on a multithreaded machine.&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons attempts to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel, especially by overloading the I/O system with identical operations.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1991</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1991"/>
		<updated>2011-08-11T02:43:25Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Setting the environment variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Just running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. To fully use the potential of &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; for running on a distributed-memory computer, you need to set the environment variables &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;, and to use a &amp;lt;tt&amp;gt;split&amp;lt;/tt&amp;gt; argument in your SConstruct Flow statements where appropriate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1990</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1990"/>
		<updated>2011-08-11T02:42:29Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* pscons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Just running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. To fully use the potential of &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; for running on a distributed-memory computer, you need to set the environment variables &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;, and to use a &amp;lt;tt&amp;gt;split&amp;lt;/tt&amp;gt; argument in your SConstruct Flow statements where appropriate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1989</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1989"/>
		<updated>2011-08-11T02:33:28Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* pscons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
To get SCons to cut your inputs into slices, run in parallel on one multi-cpu workstation or on multiple cluster nodes and then collect, use the &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; wrapper to &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. Just running pscons with no special environment variable set is equivalent to running &amp;lt;tt&amp;gt;scons -j nproc&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;nproc&amp;lt;/tt&amp;gt; is the auto-detected number of threads on your system. By setting &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Several functionalities have been added in Madagascar for parallel computing on clusters with distributed memory.&lt;br /&gt;
The &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files have to be run with &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. The command &#039;&#039;&#039;pscons&#039;&#039;&#039; is a wrapper for&lt;br /&gt;
the use of SCons with the option -j.&lt;br /&gt;
The environment variables &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; respectively provide to &#039;&#039;&#039;pscons&#039;&#039;&#039; the number of threads&lt;br /&gt;
and the address list of the nodes you want to use for your computation.&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1988</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1988"/>
		<updated>2011-08-11T02:26:56Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Options in the SConstruct file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
If &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Several functionalities have been added in Madagascar for parallel computing on clusters with distributed memory.&lt;br /&gt;
The &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files have to be run with &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. The command &#039;&#039;&#039;pscons&#039;&#039;&#039; is a wrapper for&lt;br /&gt;
the use of SCons with the option -j.&lt;br /&gt;
The environment variables &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; respectively provide to &#039;&#039;&#039;pscons&#039;&#039;&#039; the number of threads&lt;br /&gt;
and the address list of the nodes you want to use for your computation.&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1987</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1987"/>
		<updated>2011-08-11T02:25:19Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Old content below */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==pscons==&lt;br /&gt;
If &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Several functionalities have been added in Madagascar for parallel computing on clusters with distributed memory.&lt;br /&gt;
The &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files have to be run with &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. The command &#039;&#039;&#039;pscons&#039;&#039;&#039; is a wrapper for&lt;br /&gt;
the use of SCons with the option -j.&lt;br /&gt;
The environment variables &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; respectively provide to &#039;&#039;&#039;pscons&#039;&#039;&#039; the number of threads&lt;br /&gt;
and the address list of the nodes you want to use for your computation.&lt;br /&gt;
&lt;br /&gt;
== Options in the SConstruct file ==&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1986</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1986"/>
		<updated>2011-08-11T01:32:00Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Used by the Madagascar build process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Compilers==&lt;br /&gt;
Madagascar has been built successfully with the following compilers, and possibly with others:&lt;br /&gt;
* gcc&lt;br /&gt;
* Intel (icc/ifort)&lt;br /&gt;
* open64&lt;br /&gt;
* clang&lt;br /&gt;
* cc (Solaris)&lt;br /&gt;
&lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process and parallelization utilities==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_THREADS&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; to determine on how many threads to run on the local node, overriding the number of threads detected by Madagascar&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt; to determine on which cluster nodes to run, and on how many CPUs&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS, Scientific Linux, openSUSE==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
Names of packages that are runtime dependencies are &#039;&#039;&#039;highlighted&#039;&#039;&#039; in the tables below (task under construction).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==OpenSolaris==&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;pkg&amp;lt;/tt&amp;gt; to install missing components such as X11 headers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
pfexec pkg install SUNWxorg-headers&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Manual&amp;diff=1985</id>
		<title>Manual</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Manual&amp;diff=1985"/>
		<updated>2011-08-11T01:19:30Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* How to parallelize your programs */ wikified 2007-12-27 blog post&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_8418493_XS.jpg|right|]]&lt;br /&gt;
As the number of pages on the Wiki grows, the navbar starts becoming insufficient for proper organization of all documentation. A top-down view of all materials about Madagascar is also useful for determining whether gaps in coverage exist. This page will stay in the Sandbox for a long while -- until all gaps have been filled.&lt;br /&gt;
&lt;br /&gt;
Ideally the manual will only consist of either links to wiki pages, or own content. &amp;quot;Forking&amp;quot;, i.e. creating a modified copy of a page especially for the manual, invariably ends up with one version getting out of synch.&lt;br /&gt;
&lt;br /&gt;
=About Madagascar=&lt;br /&gt;
==Introduction==&lt;br /&gt;
[[Main Page]] of the wiki, and the [[Package overview]].&lt;br /&gt;
&lt;br /&gt;
==For people who do not read manuals==&lt;br /&gt;
Point them to [[Download]], [[Installation|Short Install Guide]], and the [[Revisiting SEP tour with Madagascar and SCons|SEPlib Tour Revisited]].&lt;br /&gt;
&lt;br /&gt;
==Why use Madagascar?==&lt;br /&gt;
An articulate description of the reasons on the [[Why Madagascar]] page. Have some spectacular pictures obtained with algorithms that are not present in other packages. Describe algorithms/tools unavailable in other open-source geophysical data analysis packages.&lt;br /&gt;
&lt;br /&gt;
==Community==&lt;br /&gt;
A description of the current Madagascar community, with the map of downloads and an estimate of the number of installs, who are the biggest users, outstanding research results obtained with Madagascar, etc. Links to the [http://reproducibility.org/rsflog/ blog], [https://lists.sourceforge.net/lists/listinfo/rsf-user user mailing list], [https://lists.sourceforge.net/lists/listinfo/rsf-devel developer mailing list]. Mention of the Google Groups mirrors for [http://groups.google.com/group/osdeve_mirror_geophysics_rsf-user rsf-user] and [http://groups.google.com/group/osdeve_mirror_geophysics_rsf-devel rsf-devel] Also mention the [http://sourceforge.net/tracker/?group_id=162909&amp;amp;atid=825645 bug tracker] and [http://sourceforge.net/tracker/?group_id=162909&amp;amp;atid=825648 feature request tracker], encouraging the community to use them more. Mention [http://sourceforge.net/forum/?group_id=162909 forums] as an alternative for those who want to ask questions or conduct discussions without subscribing to a mailing list.&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
A history of Madagascar, with the SEPlib/SU part of the [[Introduction_to_madagascar#Alternatives|&amp;quot;Alternatives&amp;quot; section of the Introduction]], and mentions of landmark events (short descriptions where necessary): &lt;br /&gt;
* 2003: Work started by Sergey Fomel&lt;br /&gt;
* 2004-08 (?): made available to selected alpha users&lt;br /&gt;
* 2005-02-16: RSF Blog started&lt;br /&gt;
* 2006-03-17: Registered on Sourceforge&lt;br /&gt;
* 2006-04-19: [http://www.m8r.info/rsflog/index.php?/archives/67-Madagascar.html Name change from RSF to Madagascar]&lt;br /&gt;
* 2006-06-11: Public launch at the Open Source E&amp;amp;P Software EAGE Workshop (Vienna)&lt;br /&gt;
* 2006-06-18: [http://www.m8r.info/rsflog/index.php?/archives/74-Mailing-lists-and-madagascar-0.9.1.html First stable version (0.9.1). Mailing lists created]&lt;br /&gt;
* 2006-07-23: [http://www.m8r.info/rsflog/index.php?/archives/86-New-madagascar-logo.html Madagascar logo created by Scott Rodgers (BEG)]&lt;br /&gt;
* 2007-04-27: Release 0.9.4&lt;br /&gt;
* 2007-11-10: Release 0.9.5&lt;br /&gt;
* 2008-06-14: Release 0.9.6&lt;br /&gt;
* 2009-01-03: Release 0.9.7&lt;br /&gt;
* 2009-08-01: Release 0.9.8&lt;br /&gt;
* 2010-05-02: Release 0.9.9&lt;br /&gt;
* 2010-07-23: Release 1.0&lt;br /&gt;
* For details on releases after 1.0, see [[Release Notes]]&lt;br /&gt;
&lt;br /&gt;
A link to the appendix containing the content of the [[Conferences]] and [[Publications]] pages.&lt;br /&gt;
&lt;br /&gt;
=Downloading and installing Madagascar=&lt;br /&gt;
==Download==&lt;br /&gt;
[[Download]]&lt;br /&gt;
==Install==&lt;br /&gt;
# [[Installation|Short installation guide]]&lt;br /&gt;
# [[Advanced Installation|Advanced installation guide]]&lt;br /&gt;
==Licensing and export regulations==&lt;br /&gt;
* Explanation and text of the GPL 2+&lt;br /&gt;
* [[US export control]]&lt;br /&gt;
&lt;br /&gt;
=Using Madagascar=&lt;br /&gt;
==The lightning-quick tour==&lt;br /&gt;
The [[Revisiting SEP tour with Madagascar and SCons|revisited SEP Tour]]&lt;br /&gt;
&lt;br /&gt;
==The Madagascar file formats==&lt;br /&gt;
===The Regularly Sampled Format (RSF)===&lt;br /&gt;
The current [[Guide_to_RSF_file_format|Guide to RSF file format]]&lt;br /&gt;
===Handling irregularly sampled data===&lt;br /&gt;
Explain the principle of the current method (sfheadermath/sfheaderwindow used on the trace header block output by su/segyread)&lt;br /&gt;
===Importing and exporting data from and to SEG-Y and SU===&lt;br /&gt;
sfsegyread and sfsuread, with examples&lt;br /&gt;
&lt;br /&gt;
===Importing and exporting data from and to raster images===&lt;br /&gt;
[[Raster image I/O]]&lt;br /&gt;
===Visualizing data and exporting figures with vplot===&lt;br /&gt;
* Explanation of vplot format&lt;br /&gt;
* Preempting display aliasing in raster plots with &amp;lt;tt&amp;gt;sfprep4plot&amp;lt;/tt&amp;gt;&lt;br /&gt;
* How to create vplot images with sfgraph, sfgrey, sfdots, etc. [[Common pen parameters]]&lt;br /&gt;
* How to display vplot images with sfpen. How it defaults to &amp;lt;tt&amp;gt;oglpen&amp;lt;/tt&amp;gt; on systems that support OpenGL, and &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; on systems that do not support it, but have X Windows.&lt;br /&gt;
* How to convert vplot images to other formats with &amp;lt;tt&amp;gt;vpconvert&amp;lt;/tt&amp;gt;. This tool can work on a single plot, i.e.: &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
vpconvert file.vpl file.jpg&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
or an entire collection of files:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
vpconvert format=tiff Fig/*.vpl&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;vpconvert&amp;lt;/tt&amp;gt; program can export to and from a multitude of file formats: avi, eps, gif, jpg, mpeg, pdf, png, ppm, ps, svg, and tif, and is the recommended vpl import and export tool. Older single-purpose utilities (vplot2gif and vplot2avi) are still available.&lt;br /&gt;
&lt;br /&gt;
===Visualizing data and exporting figures with GLE===&lt;br /&gt;
[[Graphics with GLE]]&lt;br /&gt;
&lt;br /&gt;
===Visualizing data and exporting figures with gnuplot===&lt;br /&gt;
[[Graphics with gnuplot]]&lt;br /&gt;
===Visualizing data and exporting figures with PLplot===&lt;br /&gt;
[http://plplot.sourceforge.net/examples.php PLplot] is a device-independent vector-plotting library. Their concept is very similar to that of vplot, but instead&lt;br /&gt;
of separated device-dependent pens (like xtpen or pspen) they use loadable &amp;quot;drivers&amp;quot; (organized as shared objects and connected to a plotting programs in a plugin fashion). They have an extensive high-level interface for different types of plots. &lt;br /&gt;
&lt;br /&gt;
A sample Madagascar program which utilizes PLplot&#039;s surface rendering capabilities is [[Guide_to_madagascar_programs#Plotting_programs_.28development.29 | sfplsurf]].&lt;br /&gt;
&lt;br /&gt;
==Calling existing Madagascar programs==&lt;br /&gt;
===Finding out what program you need===&lt;br /&gt;
# [http://reproducibility.org/rsflog/index.php?/archives/128-How-do-I-find-programs-in-madagascar.html sfdoc -k]&lt;br /&gt;
# [[Task-centric program list]] and all its subordinate nodes&lt;br /&gt;
# Collection of 2-3 page reproducible papers -- &amp;quot;How to do raytracing in Madagascar&amp;quot;; &amp;quot;How to do modeling in Madagascar&amp;quot;; etc&lt;br /&gt;
# [[SU to m8r dictionary]]&lt;br /&gt;
# [[SEPlib to m8r dictionary]]&lt;br /&gt;
# Other such dictionaries, for free or proprietary seismic processing packages. Such dictionaries are also useful because they will highlight algorithms/utilities present in such packages but missing from m8r.&lt;br /&gt;
&lt;br /&gt;
This chapter is now just a sketch, should get quite big. Users approach tools in a task-centric fashion, i.e. Q1:&amp;quot;how do I do X with Madagascar?&amp;quot;, A1:&amp;quot;With feature Y&amp;quot;; Q2: &amp;quot;How do I use feature Y to this end?&amp;quot; M8r is very good at answering Q2, but people ask Q1 first. Many of the reproducible papers included so far contain cutting-edge research. Users learning how to use Madagascar need to start with something much more simple, where they do not have to focus on understanding research on top of understanding software.&lt;br /&gt;
&lt;br /&gt;
===Learning how to use a given program===&lt;br /&gt;
# Command-line self-doc&lt;br /&gt;
# Local html self-doc (&amp;lt;tt&amp;gt;$RSFROOT/doc/index.html&amp;lt;/tt&amp;gt;). Contains all programs installed on the user&#039;s machine and only those programs.&lt;br /&gt;
# [http://reproducibility.org/RSF/ Online self-doc]&lt;br /&gt;
# The wiki [[Guide_to_madagascar_programs|Guide to Programs]].&lt;br /&gt;
# Series of dedicated reproducible papers that present the theory behind specific geophysical programs and demonstrate it with various types of inputs and combination of parameters, like [http://www.reproducibility.org/RSF/book/sep/fkamo/paper_html/paper.html this paper] does for SEPlib&#039;s AMO program.&lt;br /&gt;
# Combining together multiple programs -- the reproducible papers; pointer to relevant section of the manual (&amp;quot;Exploring reproducible papers&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==What is reproducibility==&lt;br /&gt;
The whole [[Reproducibility]] page, combined with Section 1 from [[Reproducible computational experiments using SCons]]&lt;br /&gt;
&lt;br /&gt;
==Exploring existing reproducible papers==&lt;br /&gt;
===Papers and books included in the Madagascar distribution===&lt;br /&gt;
[[Reproducible Documents]] and more.&lt;br /&gt;
&lt;br /&gt;
===How to reproduce specific figures in existing papers===&lt;br /&gt;
A frequently encountered case is when a researcher wants to reproduce only one or several figures from an entire paper, but not the entire paper. This can happen because on that system LaTeX dependencies of Madagascar are missing or not working properly, or simply because the researcher is interested only in that result.&lt;br /&gt;
# &#039;&#039;&#039;Finding the paper directory:&#039;&#039;&#039; If the interesting article has been found by browsing/hyperlink to [[Reproducible Documents]], then the reproducibility package corresponding to &amp;lt;pre&amp;gt;http://www.reproducibility.org/RSF/book/&amp;amp;lt;bookname&amp;amp;gt;/&amp;amp;lt;papername&amp;amp;gt;/paper_html/&amp;lt;/pre&amp;gt; can be found in &amp;lt;pre&amp;gt;RSFSRC/book/&amp;amp;lt;bookname&amp;amp;gt;/&amp;amp;lt;papername&amp;amp;gt;/&amp;lt;/pre&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;Finding result names:&#039;&#039;&#039; Use the html version of the paper, or grep in all &amp;lt;tt&amp;gt;.tex&amp;lt;/tt&amp;gt; files in the directory for a text string that occurs in the figure legend. Multiple-panel figures may have individual names for each panel. [Note: In pdf versions obtained with scons pdf in paper directory, neither the book name nor paper directory name nor figure names are given. LaTeX options to have figure names as well as a Geophysics-style header/footer with more details on the first page may be in order]&lt;br /&gt;
# &#039;&#039;&#039;Finding where to launch the re-build&#039;&#039;&#039;: In some cases, rules for creating a result are specified in SConstruct files in subdirectories of the main paper directory. If step 4 fails in the main paper directory, then you will have to find where the figure is built. Because result names may be generated automatically, a simple grep may not be enough and you may need to read the SConstruct and python modules imported by it to figure out if the result is generated there.&lt;br /&gt;
# &#039;&#039;&#039;Re-build&#039;&#039;&#039; and display the figure by typing &amp;lt;tt&amp;gt;scons resultname.view&amp;lt;/tt&amp;gt; in the appropriate directory.&lt;br /&gt;
&lt;br /&gt;
SConstructs containing a &amp;lt;tt&amp;gt;Fetch&amp;lt;/tt&amp;gt; instruction will attempt to download public-domain input data from a communal server when the &amp;quot;scons&amp;quot; command is run. A fast internet connection is necessary in this case.&lt;br /&gt;
&lt;br /&gt;
===How to reproduce entire papers using stored figures===&lt;br /&gt;
# See the previous section for how to find the paper directory&lt;br /&gt;
# Pointer to how to download stored figures ([[Download#Reproducible figures]])&lt;br /&gt;
*&amp;lt;tt&amp;gt;scons pdf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;scons read&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Troubleshooting:&lt;br /&gt;
* In case of failure with this kind of messages (details here), you miss TeX system dependencies. Install a TeX system. [http://www.tug.org/texlive/ Tex Live] should have it all. Note: It&#039;s a 1 Gb download. Too large for many individual users to bother with it and for most IT departments of companies to review for security. We should implement individual dependency checking, like we do in the installation. &lt;br /&gt;
* In case of failure with &amp;lt;tt&amp;gt;LaTeX Error: File `geophysics.cls&#039; not found&amp;lt;/tt&amp;gt; you have LaTeX, but you are missing [[SEGTeX]]&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons pdf&amp;lt;/tt&amp;gt; in the paper directory requires pdf figures already in place in order to work, run &amp;lt;tt&amp;gt;sftour scons lock&amp;lt;/tt&amp;gt; (?).&lt;br /&gt;
&lt;br /&gt;
===How to reproduce entire papers and all their figures===&lt;br /&gt;
# See an earlier section for how to find the paper directory&lt;br /&gt;
# The relevant SCons command (&amp;lt;tt&amp;gt;scons lock&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;sftour scons lock&amp;lt;/tt&amp;gt;, as in [[Download#Reproducible figures]] to force reproducing the figures in the paper even when the reference figures repository is present&lt;br /&gt;
&lt;br /&gt;
Tell the user to expect conditional reproducibility: If Matlab is not present, rsftex will not try to build the figures but will use the stored PDF files (same goes for Mathematica, xfig, etc.)&lt;br /&gt;
&lt;br /&gt;
===How to reproduce whole books===&lt;br /&gt;
The [http://sourceforge.net/mailarchive/forum.php?thread_name=20061222142849.9688.qmail%40web34215.mail.mud.yahoo.com&amp;amp;forum_name=rsf-user 2006-12-22 rsf-user thread], [http://reproducibility.org/rsflog/index.php?/archives/142-Assembling-reports-from-papers.html the 2007-04-08 blog entry] and more.&lt;br /&gt;
&lt;br /&gt;
From Jim&#039;s 2009-03-7 rsf-devel message:&lt;br /&gt;
Here is a way to generate all the targets in the subdirectories of $RSFSRC/book/geostats/spatial_stats:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
cd $RSFSRC/book/geostats/spatial_stats&lt;br /&gt;
sftour scons&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
That works pretty nice.  It generates all the targets in each of the 4 subdirectories of book/geostats/spatial_stats.&lt;br /&gt;
&lt;br /&gt;
Now suppose I want to capture the output and errors in a log file (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour scons &amp;gt;&amp;amp; scons.log&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
That&#039;s nice, except all the output goes into one log file in book/geostats/spatial_stats.  Suppose I want 4 separate log files, one in each of the subdirectories.  This will do the trick:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The quotes make the entire string go to sftour as the command to run in each directory, instead of just &#039;scons&#039;.&lt;br /&gt;
&lt;br /&gt;
So far so good.  Now suppose I want to go up one directory level and do the process recursively:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
cd $RSFSRC/book/geostats&lt;br /&gt;
sftour sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Well, that runs scons in each of the book/geostats/*/* directories, but it only makes 3 log files in the 3 subdirectories of book/geostats, not 14 log files in the 14 book/geostats/*/* directories.  I can get 14 separate log files like this:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour &amp;quot;sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&amp;quot;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
That does what I want.  Now suppose I want to go up one more level to $RSFSRC/book and run the process recursively three levels deep:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour sftour &amp;quot;sftour &#039;scons &amp;gt;&amp;amp; scons.log&#039;&amp;quot;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This works, but it doesn&#039;t put the log files in the bottom level, it puts them one level up.  I can&#039;t fix it the same way I did before because I&#039;ve run out of quotes :-)  Here is one way to do it (tcsh):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
foreach i (*)&lt;br /&gt;
    if ( -d $i) then&lt;br /&gt;
        echo ++++++ $i&lt;br /&gt;
        cd $i&lt;br /&gt;
        sftour &amp;quot;sftour &#039;/usr/bin/time -p scons &amp;gt;&amp;amp; scons.log&#039;&amp;quot;&lt;br /&gt;
        cd ..&lt;br /&gt;
    endif&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From Sergey&#039;s 2009-03-10 rsf-devel message: A more elegant solution is&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sftour sftour scons &amp;gt;&amp;amp; ../../%/%/scons.log&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Writing a LaTeX paper in the Madagascar framework==&lt;br /&gt;
Follows the natural progression of learning of somebody who may even not know LaTeX, let alone SCons. &lt;br /&gt;
# A paper with no figures. &lt;br /&gt;
# A paper with NR-only figures&lt;br /&gt;
==Creating a reproducible paper==&lt;br /&gt;
Sections 2 and 3 from [[Reproducible computational experiments using SCons]]. Also, mention the &amp;quot;SCons macros&amp;quot; in &amp;lt;tt&amp;gt;book/Recipes&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Publications included in Madagascar&#039;s book directories are tested periodically. Those publications that fail the tests and are not easily repaired are moved to &amp;lt;tt&amp;gt;book/Grave&amp;lt;/tt&amp;gt;, with a note on how the tests failed and why the problems could not be fixed.&lt;br /&gt;
==Data-conditional reproducibility==&lt;br /&gt;
Due to seismic data licensing terms, an author may find it possible to make public everything that is needed to make a publication reproducible, except for the data. In such conditions, the paper is still acceptable for inclusion in the Madagascar collection. To indicate that certain datasets are private, the relevant &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files should use &amp;lt;tt&amp;gt;Fetch(...,local=1)&amp;lt;/tt&amp;gt; or tt&amp;gt;Fetch(...,server=private.server)&amp;lt;/tt&amp;gt;, where &amp;lt;tt&amp;gt;private.server&amp;lt;/tt&amp;gt; is a password-protected private server. Affected  vplot figures should be uploaded to the [[Download#Reproducible figures | figure repository]]. Reproducibility testing will be skipped for the affected figures, but the html and pdf versions of the publications will still be created.&lt;br /&gt;
&lt;br /&gt;
The usage of public seismic datasets, such as those at http://software.seg.org/, is strongly encouraged.&lt;br /&gt;
&lt;br /&gt;
==Creating a reproducible book==&lt;br /&gt;
&lt;br /&gt;
=Developing in Madagascar=&lt;br /&gt;
==Writing your own programs==&lt;br /&gt;
===Introduction to the Madagascar API===&lt;br /&gt;
# The existing [[Guide_to_madagascar_API|data clipping API demo]]&lt;br /&gt;
# A more complex [[Guide_to_programming_with_madagascar|finite differences API demo]] &amp;amp;ndash; add Python, F77 and Matlab APIs to it&lt;br /&gt;
&lt;br /&gt;
===How to add your program===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#How_to_add_your_program|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===How to document your program===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#How_to_document_your_program|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===Style guide===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#Style_guide|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===How to test your program===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#How_to_test_your_program|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===How to parallelize your programs===&lt;br /&gt;
The [[Parallel Computing]] page.&lt;br /&gt;
&lt;br /&gt;
===Tips and tricks===&lt;br /&gt;
[[Adding_new_programs_to_madagascar#Tips_and_tricks|The relevant section in &amp;quot;Adding programs&amp;quot;]]&lt;br /&gt;
&lt;br /&gt;
===Madagascar library reference===&lt;br /&gt;
* [[Library Reference]]&lt;br /&gt;
* The [http://m8r.info/rsf_epydoc/ Python API documentation]&lt;br /&gt;
* The [http://m8r.info/RSF/book/rsf/manual/manual_html/ Programming Reference Manual]&lt;br /&gt;
&lt;br /&gt;
==Adding programs to the central repository==&lt;br /&gt;
==Framework development and maintenance==&lt;br /&gt;
Description of m8r&#039;s inner works for those who want to help improve and maintain Madagascar. [[Maintenance guide]] and perhaps other stuff.&lt;br /&gt;
==Graphics development with vplot==&lt;br /&gt;
[[Graphics development with vplot]]&lt;br /&gt;
==Packaging madagascar==&lt;br /&gt;
[[Packaging madagascar]]&lt;br /&gt;
&lt;br /&gt;
=Datasets distributed with Madagascar=&lt;br /&gt;
* Description of datasets &amp;amp;ndash; pictures of the velocity model, of sample gathers, zero-offset sections, migrated image.&lt;br /&gt;
* Comment on which are the main problems they illustrate (internal multiples? overturning waves? etc). Algorithm used for generating them, references to published literature describing the datasets&lt;br /&gt;
* Command line options for correctly reading them from the storage format (SEG-Y, most probably) into RSF&lt;br /&gt;
* In general, expand the [[Reproducible_Documents#Madagascar_Datasets | datasets section of Reproducible Documents page]] to include other datasets&lt;br /&gt;
&lt;br /&gt;
=Other open-source data analysis packages=&lt;br /&gt;
==Geophysical software==&lt;br /&gt;
[[Other open-source geophysical packages]]. Briefly discuss each of them. Mention &amp;quot;dictionaries&amp;quot; from them to m8r where available (should attempt to have dictionaries for all of them)&lt;br /&gt;
&lt;br /&gt;
==Other tools==&lt;br /&gt;
There are many other useful open-source or public domain software tools in the domain of applied mathematics, that can be used complementary to Madagascar. A few common examples, in alphabetical order, are:&lt;br /&gt;
&lt;br /&gt;
* [http://www.alglib.net/ ALGLIB]: a highly portable numerical analysis and data processing library;&lt;br /&gt;
* [http://www.caam.rice.edu/software/ARPACK/ ARPACK] (&amp;quot;The ARnoldi PACKage&amp;quot;): a library written in FORTRAN 77 for solving large-scale eigenvalue problems;&lt;br /&gt;
* [http://math-atlas.sourceforge.net/ ATLAS] (&amp;quot;Automatically Tuned Linear Algebra Software&amp;quot;): a linear algebra library, implementing the [http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms BLAS] APIs for C and Fortran77;&lt;br /&gt;
* [http://www.oonumerics.org/blitz/ Blitz++]: a C++ class library for scientific computing which provides performance on par with Fortran 77/90;&lt;br /&gt;
* [http://www.dune-project.org/ DUNE] (&amp;quot;Distributed and Unified Numerics Environment&amp;quot;): a modular toolbox for solving partial differential equations with grid-based methods. It supports the easy implementation of methods like Finite Elements, Finite Volumes, and also Finite Differences. &lt;br /&gt;
* [http://fftw.org/ FFTW] (&amp;quot;The Fastest Fourier Transform in the West&amp;quot;): Hardware-adaptive FFT libraries;&lt;br /&gt;
* [http://www.gnu.org/software/gsl/ GNU Scientific Library]: a C library for numerical calculations in many branches of applied mathematics and science;&lt;br /&gt;
* [http://gts.sourceforge.net/index.html GNU Triangulated Surface Library]: a library providing a set of useful functions to deal with 3D surfaces meshed with interconnected triangles;&lt;br /&gt;
* [http://www.netlib.org/lapack/ LAPACK] (&amp;quot;The Linear Algebra PACKage&amp;quot;): a collection of routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/MINPACK MINPACK]: a library of FORTRAN subroutines for the solving of systems of nonlinear equations, or the least squares minimization of the residual of a set of linear or nonlinear equations;&lt;br /&gt;
* [http://www.mcs.anl.gov/petsc/petsc-2/ PETSc] (&amp;quot;the Portable, Extensible Toolkit for Scientific computation&amp;quot;): A set of serial and parallel, linear and nonlinear, solvers for large-scale, sparse linear and nonlinear systems of equations;&lt;br /&gt;
* [http://www.scipy.org/ SciPY] (&amp;quot;Scientific Python&amp;quot;): a toolbox for scientific computing in Python;&lt;br /&gt;
* [http://www.boost.org/doc/libs/1_39_0/libs/numeric/ublas/doc/index.htm uBLAS]: a C++ template class library that provides BLAS level 1, 2, 3 functionality for dense, packed and sparse matrices.&lt;br /&gt;
&lt;br /&gt;
Most [http://en.wikipedia.org/ Wikipedia] pages of the above libraries are valuable resources, as is Wikipedia&#039;s [http://en.wikipedia.org/wiki/List_of_numerical_analysis_software list of numerical analysis software]. Other libraries and standalone programs are available through the [http://www.netlib.org/ Netlib repository] and indexed by the [http://gams.nist.gov/ Guide to Available Mathematical Software]. The U.S. DOE&#039;s [http://acts.nersc.gov/ ACTS Collection] is another valuable repository.&lt;br /&gt;
&lt;br /&gt;
==Madagascar in conferences and publications==&lt;br /&gt;
The content of the [[Conferences]] and [[Publications]] pages. A mention about the reproducible documents that are listed in the &amp;quot;Papers and books included in the Madagascar distribution&amp;quot; sections.&lt;br /&gt;
==Madagascar project system administrator&#039;s guide==&lt;br /&gt;
[[Mediawiki installation, customization and operation]]&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1984</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1984"/>
		<updated>2011-08-11T01:17:27Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* MPI (external) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==MPI + OpenMP (both external)==&lt;br /&gt;
&lt;br /&gt;
It is possible to combine the advantages of shared-memory and distributed-memory architectures by using OpenMP and MPI together.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 32 sfmpi sfomp sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
will distribute the job on 32 nodes and split it again on each node using shared-memory threads.&lt;br /&gt;
&lt;br /&gt;
==Old content below==&lt;br /&gt;
&lt;br /&gt;
Several functionalities have been added in Madagascar for parallel computing on clusters with distributed memory.&lt;br /&gt;
The &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files have to be run with &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. The command &#039;&#039;&#039;pscons&#039;&#039;&#039; is a wrapper for&lt;br /&gt;
the use of SCons with the option -j.&lt;br /&gt;
The environment variables &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; respectively provide to &#039;&#039;&#039;pscons&#039;&#039;&#039; the number of threads&lt;br /&gt;
and the address list of the nodes you want to use for your computation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Options in the SConstruct file ==&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1983</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1983"/>
		<updated>2011-08-11T01:16:14Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* OpenMP (internal) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
On the last check (2011-08-10), 84 standalone programs (approximately 10% of Madagascar programs) were using OMP. Running this command in the directory &amp;lt;tt&amp;gt;$RSFSRC/api/c&amp;lt;/tt&amp;gt; will yield a few functions parallelized with OMP (among which a Fourier Transform).&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==Old content below==&lt;br /&gt;
&lt;br /&gt;
Several functionalities have been added in Madagascar for parallel computing on clusters with distributed memory.&lt;br /&gt;
The &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files have to be run with &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. The command &#039;&#039;&#039;pscons&#039;&#039;&#039; is a wrapper for&lt;br /&gt;
the use of SCons with the option -j.&lt;br /&gt;
The environment variables &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; respectively provide to &#039;&#039;&#039;pscons&#039;&#039;&#039; the number of threads&lt;br /&gt;
and the address list of the nodes you want to use for your computation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Options in the SConstruct file ==&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1982</id>
		<title>Parallel Computing</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Parallel_Computing&amp;diff=1982"/>
		<updated>2011-08-11T01:09:39Z</updated>

		<summary type="html">&lt;p&gt;Nick: Merging page with 2007-12-27 post and with new info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many of the data processing operations are &#039;&#039;&#039;data-parallel&#039;&#039;&#039;: different traces, shot gathers, frequency slices, etc. can be processed independently. Madagascar provides several mechanisms for handling this type of embarrassingly parallel applications on computers with multiple processors. &lt;br /&gt;
&lt;br /&gt;
==OpenMP (internal)==&lt;br /&gt;
[https://secure.wikimedia.org/wikipedia/en/wiki/OpenMP OpenMP] is a standard framework for parallel applications on &#039;&#039;&#039;shared-memory&#039;&#039;&#039; systems. It is supported by the latest versions of [http://gcc.gnu.org/ GCC] and by some other compilers.&lt;br /&gt;
&lt;br /&gt;
To use OpenMP in your program, you do not need to add anything to your SConstruct. Just make sure the OMP libraries are installed on your system before you configure Madagascar, (or -- reinstall them and rerun the configuration command). Of course, you need to use the appropriate pragmas in your code. To find Madagascar programs that use OpenMP and that you can take as a model, run the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep &amp;quot;pragma omp&amp;quot; $RSFSRC/user/*/*.c |\&lt;br /&gt;
awk -F &#039;:&#039; &#039;{ print $1 }&#039; |\&lt;br /&gt;
uniq |\&lt;br /&gt;
awk -F &#039;/&#039; &#039;{ print $NF }&#039; |\&lt;br /&gt;
grep M |\&lt;br /&gt;
wc -l&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==OpenMP (external)==&lt;br /&gt;
&lt;br /&gt;
To run on a multi-core shared-memory machine a data-parallel process that does not contain OpenMP calls, use &amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt;. Thus, a call like&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
becomes&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfomp sfradon np=100 p0=0 dp=0.01 &amp;lt; inp.rsf &amp;gt; out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfomp&amp;lt;/tt&amp;gt; splits the input along the slowest axis (presumed to be data-parallel) and runs it through parallel threads. The number of threads is set by the &amp;lt;tt&amp;gt;OMP_NUM_THREADS&amp;lt;/tt&amp;gt; environmental variable or (by default) by the number of available CPUs.&lt;br /&gt;
&lt;br /&gt;
==MPI (internal)==&lt;br /&gt;
[http://www.mcs.anl.gov/research/projects/mpi/ MPI] (Message-Passing Interface) is the dominant standard framework for parallel processing on different computer architectures including &#039;&#039;&#039;distributed-memory&#039;&#039;&#039; systems. Several MPI implementations (such as [http://www.open-mpi.org/ Open MPI] and [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2]) are available.&lt;br /&gt;
&lt;br /&gt;
An example of compiling a program with &amp;lt;tt&amp;gt;mpicc&amp;lt;/tt&amp;gt; and running it under &amp;lt;tt&amp;gt;mpirun&amp;lt;/tt&amp;gt; can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/bash/mpi/SConstruct?view=markup $RSFSRC/book/rsf/bash/mpi/SConstruct]&lt;br /&gt;
&lt;br /&gt;
==MPI (external)==&lt;br /&gt;
To parallelize a task using MPI but without including MPI calls in your source code, try &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
mpirun -np 8 sfmpi sfradon np=100 p0=0 dp=0.01 input=inp.rsf output=out.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
where the argument after &amp;lt;tt&amp;gt;-np&amp;lt;/tt&amp;gt; specifies the number of processors involved. sfmpi will use this number to split the input along the slowest axis (presumed to be data-parallel) and to run it through parallel threads. Notice that the keywords &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;output&amp;lt;/tt&amp;gt; are specific to &amp;lt;tt&amp;gt;sfmpi&amp;lt;/tt&amp;gt; and they will be used to specify the standard input and output streams of your program.&lt;br /&gt;
&lt;br /&gt;
Some MPI implementations do not support system calls implemented in sfmpi and therefore will not support this feature.&lt;br /&gt;
&lt;br /&gt;
==Old content below==&lt;br /&gt;
&lt;br /&gt;
Several functionalities have been added in Madagascar for parallel computing on clusters with distributed memory.&lt;br /&gt;
The &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; files have to be run with &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;. The command &#039;&#039;&#039;pscons&#039;&#039;&#039; is a wrapper for&lt;br /&gt;
the use of SCons with the option -j.&lt;br /&gt;
The environment variables &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; respectively provide to &#039;&#039;&#039;pscons&#039;&#039;&#039; the number of threads&lt;br /&gt;
and the address list of the nodes you want to use for your computation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Options in the SConstruct file ==&lt;br /&gt;
&lt;br /&gt;
=== Computing on the local node only by using the option local=1 ===&lt;br /&gt;
&lt;br /&gt;
By default, with &#039;&#039;&#039;pscons&#039;&#039;&#039;, SCons wants to run all the commands of the &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file in parallel.&lt;br /&gt;
The option &#039;&#039;&#039;local=1&#039;&#039;&#039; forces SCons to compute locally. It can be very useful in order to prevent serial&lt;br /&gt;
parts of your python script to be run inefficiently in parallel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;,local=1)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computing on the nodes of the cluster specified by the environment variable &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;,split=[3,1000],reduce=&#039;cat&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;split&#039;&#039;&#039; instructs &#039;&#039;&#039;Flow&#039;&#039;&#039; to split the input file along the third axis of length 1000. &lt;br /&gt;
If you have several source files and want to split only some of them, say the first and the third one, the option to use will be &#039;&#039;&#039;split&#039;&#039;&#039;=[3,1000,[0,2]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If we choose &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_THREADS&amp;lt;/tt&amp;gt;=26, we obtain, as an itermediate result in the local directory, the files&lt;br /&gt;
&amp;lt;tt&amp;gt;spike__0.rsf, spike__1.rsf, ..., spike__25.rsf,&amp;lt;/tt&amp;gt; which are sent and distributed for computation on the different nodes&lt;br /&gt;
specified by &amp;lt;tt&amp;gt;&amp;amp;#36;RSF_CLUSTER&amp;lt;/tt&amp;gt;.&lt;br /&gt;
After the parallel computation on the nodes, the resulting files &lt;br /&gt;
&amp;lt;tt&amp;gt;radon__0.rsf, radon__1.rsf, ..., radon__25.rsf&amp;lt;/tt&amp;gt;, are recombined together to create the output &amp;lt;tt&amp;gt;radon.rsf&amp;lt;/tt&amp;gt;.&lt;br /&gt;
The parameter &#039;&#039;&#039;reduce&#039;&#039;&#039; selects the type of recombination. Two typical options are &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;cat&#039; or &#039;&#039;&#039;reduce&#039;&#039;&#039;=&#039;add&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Computing in parallel without using any option ===&lt;br /&gt;
&lt;br /&gt;
This choice is appropriate when you write a python loop in your program&lt;br /&gt;
and want it to be run in parallel. This is a way, as well, to speed up sequential parts of your program. &lt;br /&gt;
However, the user should make judicious decisions as it can have the opposite effect.&lt;br /&gt;
Indeed, in a serial part of the program, the second command has to wait for the first to finish the run on a different node and to communicate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
Flow(&#039;spike&#039;,None,&#039;spike n1=100 n2=300 n3=1000&#039;)&lt;br /&gt;
Flow(&#039;radon&#039;,&#039;spike&#039;,&#039;radon adj=y p0=-4 np=200 dp=0.04&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting the environment variables ==&lt;br /&gt;
&lt;br /&gt;
In our example, we used 26 threads and send them on 4 nodes, using&lt;br /&gt;
respectively 6 CPUs on the first node, 4 CPUs on the second, and 8 CPUs&lt;br /&gt;
on each of the last two nodes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSF_THREADS=26&lt;br /&gt;
export RSF_CLUSTER=&#039;140.168.1.236 6 140.168.1.235 4 140.168.1.234 8 140.168.1.233 8&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One important setting is to properly manage the temporary files location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; &lt;br /&gt;
and the data storage location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; .&lt;br /&gt;
The temporary files used during the computation have to be stored locally on each node to avoid too much communication&lt;br /&gt;
between the hard disks and the nodes.&lt;br /&gt;
The paths will depend on your cluster and you can set them in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt; file, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export DATAPATH=/disk1/data/myname/&lt;br /&gt;
export TMPDATAPATH=/tmp/&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Run ==&lt;br /&gt;
&lt;br /&gt;
Once your &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; file is ready and your environment variables are set,&lt;br /&gt;
you can use the following suggested procedure.&lt;br /&gt;
It has been tested and is currently used on a linux cluster.&lt;br /&gt;
&lt;br /&gt;
* Make sure the disk located at &amp;lt;tt&amp;gt;&amp;amp;#36;DATAPATH&amp;lt;/tt&amp;gt; is mounted on the different nodes.&lt;br /&gt;
* Test if there is enough space available on the different nodes of the cluster at the location specified by &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt;. This directory may be filled up, if some jobs have been interrupted. Clean this up if necessary.&lt;br /&gt;
* Look at what is going on on your cluster with &#039;&#039;&#039;sftop&#039;&#039;&#039;.&lt;br /&gt;
* Everything looks good ? Then go and run &#039;&#039;&#039;pscons&#039;&#039;&#039; instead of &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* If you need to kill your processes on the cluster, the command &#039;&#039;&#039;sfkill&#039;&#039;&#039; can do it remotely on all the nodes for a specific job command. If you kill your jobs, check it did not filled up the &amp;lt;tt&amp;gt;&amp;amp;#36;TMPDATAPATH&amp;lt;/tt&amp;gt; with temporary files before you run &#039;&#039;&#039;pscons&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
One nice feature of running SCons on clusters is fault tolerance (see [http://www.reproducibility.org/rsflog/index.php?/archives/160-Parallel-processing.html relevant blog post]).&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Seismic_task-centric_program_list&amp;diff=1981</id>
		<title>Seismic task-centric program list</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Seismic_task-centric_program_list&amp;diff=1981"/>
		<updated>2011-08-09T03:00:27Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Elastic modeling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_369804_XS.jpg|right|]]&lt;br /&gt;
This page presents a list of programs for seismic processing, imaging and analysis. An overview of all task-centric pages can be found in the main [[Task-centric program list]].&lt;br /&gt;
&lt;br /&gt;
The most frequent question encountered from a new user is: &amp;quot;Does Madagascar do [some needed process]?&amp;quot; The first level of classification is therefore by types of geophysical procedures. Then the classifications below try to follow&#039;s the user&#039;s workflow:&lt;br /&gt;
# What sort of data must be processed/imaged: 3-D, 2-D, prestack, poststack?&lt;br /&gt;
# If a velocity model is needed, which sort is available? A v(x,z) one, a v(z) or a constant velocity?&lt;br /&gt;
# Which algorithm to use if several are available.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;All program names below should be prefixed with &amp;quot;sf&amp;quot;.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=Manipulating irregular datasets, regularization and sorting=&lt;br /&gt;
* Integer header attributes: [http://reproducibility.org/RSF/sfheaderattr.html headerattr]&lt;br /&gt;
* Zero a portion of a dataset based on a header mask: [http://reproducibility.org/RSF/sfheadercut.html headercut]&lt;br /&gt;
* Mathematical operations, possibly on header keys: [http://reproducibility.org/RSF/sfheadermath.html headermath]&lt;br /&gt;
* Sort a dataset according to a header key: [http://reproducibility.org/RSF/sfheadersort.html headersort]&lt;br /&gt;
* Window a dataset based on a header mask: [http://reproducibility.org/RSF/sfheaderwindow.html headerwindow]&lt;br /&gt;
* Create a mask: [http://reproducibility.org/RSF/sfmask.html mask]&lt;br /&gt;
* Shot interpolation: [http://reproducibility.org/RSF/sfinfill.html infill]&lt;br /&gt;
* Data binning (geometry regularization): [http://reproducibility.org/RSF/sfintbin.html intbin] (works especially for basically regular geometries but with skipped or resorted traces)&lt;br /&gt;
* Data binning in 1-D slices: [http://reproducibility.org/RSF/sfbin1.html bin1]&lt;br /&gt;
* Data binning in 2-D slices: [http://reproducibility.org/RSF/sfbin.html bin]&lt;br /&gt;
* Data regularization in 2-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanereg2.html planereg2]&lt;br /&gt;
* Data regularization in 3-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanereg3.html planereg3]&lt;br /&gt;
* Convert CMPs to shots for regular 2-D geometry: [http://reproducibility.org/RSF/sfcmp2shot.html cmp2shot]&lt;br /&gt;
* Convert shots to CMPs for regular 2-D geometry: [http://reproducibility.org/RSF/sfshot2cmp.html shot2cmp]&lt;br /&gt;
* 2-D fold maps: [http://ahay.org/RSF/sfhist2.html hist2]&lt;br /&gt;
&lt;br /&gt;
=Interpolation tools=&lt;br /&gt;
==Making holes==&lt;br /&gt;
* Cut an elliptic hole in data (for interpolation tests): [http://reproducibility.org/RSF/sfhole.html hole]&lt;br /&gt;
* Create a synthetic irregular dataset for interpolation tests: [http://reproducibility.org/RSF/sfsyntop.html syntop]&lt;br /&gt;
==Actual interpolation==&lt;br /&gt;
* Linear interpolation: [http://reproducibility.org/RSF/sflint1.html lint1]&lt;br /&gt;
* 1-D cubic spline interpolation: [http://reproducibility.org/RSF/sfspline.html spline]&lt;br /&gt;
* Data interpolation in 2-D slices using helix preconditioning: [http://reproducibility.org/RSF/sfinvbin.html invbin]&lt;br /&gt;
* 1-D inverse interpolation: [http://reproducibility.org/RSF/sfinvbin1.html invbin1]&lt;br /&gt;
* Leveler inverse interpolation in 1-D: [http://reproducibility.org/RSF/sflevint.html levint]&lt;br /&gt;
* Find MISSing Input values and Filter in 1-D: [http://reproducibility.org/RSF/sfmisif.html misif]&lt;br /&gt;
* Missing data interpolation in 1-D: [http://reproducibility.org/RSF/sfmiss1.html miss1]&lt;br /&gt;
* 2-D missing data interpolation: [http://reproducibility.org/RSF/sfmiss2.html miss2]&lt;br /&gt;
* Missing data interpolation (N-dimensional) using shaping regularization: [http://reproducibility.org/RSF/sfmiss3.html miss3]&lt;br /&gt;
* Multi-dimensional missing data interpolation: [http://reproducibility.org/RSF/sfmiss.html miss]&lt;br /&gt;
* Multiscale missing data interpolation (N-dimensional): [http://reproducibility.org/RSF/sfmsmiss.html msmiss]&lt;br /&gt;
* 2-D missing data interpolation by differential offset continuation: [http://reproducibility.org/RSF/sfofilp.html ofilp]&lt;br /&gt;
* 1-D ENO (Essentially Non Oscillatory) interpolation: [http://reproducibility.org/RSF/sfremap1.html remap1]&lt;br /&gt;
* ENO interpolation in 2-D slices: [http://reproducibility.org/RSF/sfenoint2.html enoint2]&lt;br /&gt;
* 2-D trace interpolation to a denser grid using PWD (&amp;quot;beyond aliasing&amp;quot; method): [http://reproducibility.org/RSF/sfdealias.html dealias]&lt;br /&gt;
* Shot interpolation: [http://reproducibility.org/RSF/sfinfill.html infill]&lt;br /&gt;
* Testing forward interpolation in 1-D: [http://reproducibility.org/RSF/sfinttest1.html inttest1]&lt;br /&gt;
* Testing forward interpolation in 2-D: [http://reproducibility.org/RSF/sfinttest2.html inttest2]&lt;br /&gt;
* Missing data interpolation in 2-D by Laplacian regularization: [http://reproducibility.org/RSF/sflapfill.html lapfill]&lt;br /&gt;
* Missing data interpolation using one or two prediction-error filters: [http://reproducibility.org/RSF/sfmaskinv.html maskinv]&lt;br /&gt;
* Missing data interpolation in 2-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanemis2.html planemis2]&lt;br /&gt;
* Missing data interpolation in 3-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanemis3.html planemis3]&lt;br /&gt;
* Missing data interpolation in 2-D using plane-wave destruction and shaping regularization: [http://reproducibility.org/RSF/sfpmshape2.html pmshape2]&lt;br /&gt;
&lt;br /&gt;
=Classic preprocessing=&lt;br /&gt;
Excludes: (1) denoising; (2) moveouts/stretches, and (3) interpolations, which will get their own sections.&lt;br /&gt;
* Stretch of the time axis:  [[Guide_to_madagascar_programs#sfstretch | stretch guide]], [http://reproducibility.org/RSF/sfstretch.html stretch]&lt;br /&gt;
* Amplitude balancing: [http://reproducibility.org/RSF/sfabalance.html abalance]&lt;br /&gt;
* Compute data envelope: [http://reproducibility.org/RSF/sfenvelope.html envelope]&lt;br /&gt;
* Automatic gain control: [http://reproducibility.org/RSF/sfagc.html agc]&lt;br /&gt;
* Bandpass filtering: [http://reproducibility.org/RSF/sfbandpass.html bandpass]&lt;br /&gt;
* Bandpass filtering using erf function: [http://reproducibility.org/RSF/sferf.html erf]&lt;br /&gt;
* Deconvolution (N-dimensional): [http://reproducibility.org/RSF/sfdecon.html decon]&lt;br /&gt;
* 1-D convolution: [http://reproducibility.org/RSF/sfconv.html conv]&lt;br /&gt;
* Dip filtering (2-D or 3-D): [http://reproducibility.org/RSF/sfdipfilter.html dipfilter]&lt;br /&gt;
* Muting: [http://reproducibility.org/RSF/sfmutter.html mutter]&lt;br /&gt;
* Stack a dataset over one of the dimensions: [http://reproducibility.org/RSF/sfstack.html stack]&lt;br /&gt;
* Time power gain: [http://reproducibility.org/RSF/sftpow.html tpow]&lt;br /&gt;
* Frequency spectra: [http://reproducibility.org/RSF/sfspectra.html spectra]&lt;br /&gt;
* Frequency spectra in 2-D: [http://reproducibility.org/RSF/sfspectra2.html spectra2]&lt;br /&gt;
* Static correction: [http://reproducibility.org/RSF/sfstretch.html datstretch]. Use the the &amp;lt;tt&amp;gt;datum=&amp;lt;/tt&amp;gt; parameter to specify file holding time shifts.&lt;br /&gt;
&lt;br /&gt;
=Wavelet estimation=&lt;br /&gt;
* Mono-frequency wavelet estimation: [http://reproducibility.org/RSF/sfmonof.html monof]&lt;br /&gt;
* Gaussian wavelet estimation in 2-D: [http://reproducibility.org/RSF/sfmonof2.html monof2]&lt;br /&gt;
* Ricker wavelet estimation: [http://reproducibility.org/RSF/sfricker.html ricker]&lt;br /&gt;
&lt;br /&gt;
=Denoising/S-N separation=&lt;br /&gt;
* Denoising using stationary wavelet transform: [http://reproducibility.org/RSF/sfswtdenoise.html swtdenoise]&lt;br /&gt;
* Remove bursty noise by IRLS: [http://reproducibility.org/RSF/sfdeburst.html deburst]&lt;br /&gt;
* Burst noise removal using PEF: [http://reproducibility.org/RSF/sfpefdeburst.html pefdeburst]&lt;br /&gt;
* Remove spikes in by sliding 1-D medians: [http://reproducibility.org/RSF/sfdespike.html despike]&lt;br /&gt;
* Remove spikes in by sliding 2-D medians: [http://reproducibility.org/RSF/sfdespike2.html despike2]&lt;br /&gt;
* Remove spikes in by sliding 3-D medians: [http://reproducibility.org/RSF/sfdespike3.html despike3]&lt;br /&gt;
* Signal and noise separation (N-dimensional): [http://reproducibility.org/RSF/sfsignoi.html signoi]&lt;br /&gt;
* Local signal and noise separation (N-dimensional): [http://reproducibility.org/RSF/sflosignoi.html losignoi]&lt;br /&gt;
* Signal and noise separation using plane-wave destruction filters: [http://reproducibility.org/RSF/sfplanesignoi.html planesignoi]&lt;br /&gt;
* Signal and noise separation using both frequency components and dips: [http://reproducibility.org/RSF/sfexplanesignoi.html explanesignoi]&lt;br /&gt;
* Signal and noise separation using frequency components: [http://reproducibility.org/RSF/sfexpsignoi.html expsignoi]&lt;br /&gt;
&lt;br /&gt;
=Tracewise stretch/moveout operators=&lt;br /&gt;
These operators do not carry energy from one trace to the other. The operation can be performed independently on each trace.&lt;br /&gt;
* General stretch of the time axis: [http://reproducibility.org/RSF/sfstretch.html stretch]&lt;br /&gt;
* Constant-velocity Normal Moveout stretch: [http://reproducibility.org/RSF/sfstretch.html nmostretch]&lt;br /&gt;
* Linear Moveout stretch: [http://reproducibility.org/RSF/sfstretch.html lmostretch]&lt;br /&gt;
* Log stretch: [http://reproducibility.org/RSF/sfstretch.html logstretch]&lt;br /&gt;
* T-square stretch: [http://reproducibility.org/RSF/sfstretch.html t2stretch]&lt;br /&gt;
* T-square Chebyshev stretch: [http://reproducibility.org/RSF/sfstretch.html t2chebstretch]&lt;br /&gt;
* Radial moveout: [http://reproducibility.org/RSF/sfstretch.html radstretch]&lt;br /&gt;
* Datuming stretch: [http://reproducibility.org/RSF/sfstretch.html datstretch]&lt;br /&gt;
* Normal moveout: [http://reproducibility.org/RSF/sfnmo.html nmo]&lt;br /&gt;
* Inverse normal moveout: [http://reproducibility.org/RSF/sfinmo.html inmo]&lt;br /&gt;
* Constant-velocity nearest-neighbor inverse NMO: [http://reproducibility.org/RSF/sfimospray.html imospray]&lt;br /&gt;
* Normal moveout in tau-p domain: [http://reproducibility.org/RSF/sftaupmo.html taupmo]&lt;br /&gt;
* Slope-based normal moveout: [http://reproducibility.org/RSF/sfpnmo.html pnmo]&lt;br /&gt;
&lt;br /&gt;
=DMO/AMO/Offset continuation=&lt;br /&gt;
* Kirchhoff DMO with antialiasing by reparameterization: [http://reproducibility.org/RSF/sfdmo.html dmo]&lt;br /&gt;
* Azimuth moveout by log-stretch F-K operator: [http://reproducibility.org/RSF/sffkamo.html fkamo]&lt;br /&gt;
* Offset continuation by log-stretch F-K operator: [http://reproducibility.org/RSF/sffkdmo.html fkdmo]&lt;br /&gt;
* Offset continuation by finite differences: [http://reproducibility.org/RSF/sffincon.html fincon]&lt;br /&gt;
* DMO and stack by finite-difference offset continuation: [http://reproducibility.org/RSF/sffinstack.html finstack]&lt;br /&gt;
&lt;br /&gt;
=Whole-image stretching=&lt;br /&gt;
* Stolt stretch: [http://reproducibility.org/RSF/sfstoltstretch.html stoltstretch]&lt;br /&gt;
* Cartesian-Coordinates to Riemannian-Coordinates interpolation: [http://reproducibility.org/RSF/sfc2r.html c2r]&lt;br /&gt;
&lt;br /&gt;
=Autopicking=&lt;br /&gt;
* Automatic picking from semblance-like panels: [http://reproducibility.org/RSF/sfpick.html pick], [http://reproducibility.org/RSF/sfpick2.html pick2]&lt;br /&gt;
* Generate stereopicks from time-migration velocities and slopes: [http://reproducibility.org/RSF/sfpgen.html pgen]&lt;br /&gt;
* Generate stereotomography picks from time migration: [http://reproducibility.org/RSF/sfspicks.html spicks]&lt;br /&gt;
* Picking local maxima on the first axis: [http://reproducibility.org/RSF/sfmax1.html max1]&lt;br /&gt;
* Picking by plane-wave construction: [http://reproducibility.org/RSF/sfpwpick.html pwpick]&lt;br /&gt;
* Preconditioning for traveltime picking: [http://reproducibility.org/RSF/sfshearer.html shearer]&lt;br /&gt;
&lt;br /&gt;
=Velocity analysis=&lt;br /&gt;
* Velocity transform: [http://reproducibility.org/RSF/sfvelmod.html velmod]&lt;br /&gt;
* Slope-based velocity transform: [http://reproducibility.org/RSF/sfpveltran.html pveltran]&lt;br /&gt;
* Hyperbolic Radon transform: [http://reproducibility.org/RSF/sfveltran.html veltran]&lt;br /&gt;
* Hyperbolic Radon transform with conjugate-directions inversion: [http://reproducibility.org/RSF/sfcgscan.html cgscan]&lt;br /&gt;
* Velocity analysis: [http://reproducibility.org/RSF/sfvscan.html vscan]&lt;br /&gt;
* 3-D zero-offset WEMVA: [http://reproducibility.org/RSF/sfzomva.html zomva]&lt;br /&gt;
* 3-D S/R WEMVA with extended split-step: [http://reproducibility.org/RSF/sfsrmva.html srmva]&lt;br /&gt;
* Simple tomography test: [http://reproducibility.org/RSF/sftomo.html tomo]&lt;br /&gt;
&lt;br /&gt;
=Velocity continuation=&lt;br /&gt;
* Post-stack 2-D velocity continuation by Chebyshev-tau method: [http://reproducibility.org/RSF/sfchebvc.html chebvc]&lt;br /&gt;
* Velocity continuation: [http://reproducibility.org/RSF/sffourvc.html fourvc]&lt;br /&gt;
* Velocity continuation after NMO: [http://reproducibility.org/RSF/sffourvc0.html fourvc0]&lt;br /&gt;
* Velocity continuation with semblance computation: [http://reproducibility.org/RSF/sffourvc2.html fourvc2]&lt;br /&gt;
* Post-stack velocity continuation by implicit finite differences: [http://reproducibility.org/RSF/sfvelcon.html velcon]&lt;br /&gt;
* 3-D finite-difference velocity continuation on a helix: [http://reproducibility.org/RSF/sfvelcon3.html velcon3]&lt;br /&gt;
&lt;br /&gt;
=Velocity and data converters=&lt;br /&gt;
* Convert RMS to interval velocity: [http://reproducibility.org/RSF/sfdix.html dix]&lt;br /&gt;
* Convert RMS to interval velocity using LS and shaping regularization: [http://reproducibility.org/RSF/sfdixshape.html dixshape]&lt;br /&gt;
* V(t) function for a linear V(Z) profile: [http://reproducibility.org/RSF/sfvoft.html voft]&lt;br /&gt;
* Conversion from depth to time in a V(z) medium: [http://reproducibility.org/RSF/sfdepth2time.html depth2time]&lt;br /&gt;
* Time-to-depth conversion in V(z): [http://reproducibility.org/RSF/sftime2depth.html time2depth]&lt;br /&gt;
* Convert RMS to interval velocity using LS and plane-wave construction: [http://reproducibility.org/RSF/sfpwdix.html pwdix]&lt;br /&gt;
&lt;br /&gt;
=Ray tracing=&lt;br /&gt;
The programs below take as input a velocity model and output ray trajectories.&lt;br /&gt;
==2-D, v(x,z)==&lt;br /&gt;
* Huygens wavefront tracing: [http://reproducibility.org/RSF/sfhwt2d.html hwt2d]&lt;br /&gt;
* For layered media: [http://reproducibility.org/RSF/sflayer.html layer]&lt;br /&gt;
* Second-order cell ray tracing with locally parabolic rays: [http://reproducibility.org/RSF/sfcell2.html cell2].&lt;br /&gt;
* Ray tracing by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2.html rays2]&lt;br /&gt;
==2-D, v(x,z), anisotropic media==&lt;br /&gt;
* Ray tracing in VTI media by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2a.html rays2a]&lt;br /&gt;
==2-D, v(x,z), multiples==&lt;br /&gt;
* By cell ray tracing: [http://reproducibility.org/RSF/sftrace2.html trace2]&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
* Plot rays: [http://reproducibility.org/RSF/sfplotrays.html plotrays]&lt;br /&gt;
* Plot rays in 3D with OpenGL: [http://reproducibility.org/RSF/sfplotrays3.html plotsray3]&lt;br /&gt;
&lt;br /&gt;
=Traveltimes computation=&lt;br /&gt;
* Analytical traveltime in 2-D, linear v(z): [http://reproducibility.org/RSF/sfvofz.html vofz]&lt;br /&gt;
* Huygens wavefront tracing (ray-based method): [http://reproducibility.org/RSF/sfhwtex.html hwtex], [http://reproducibility.org/RSF/sfhwt2d.html hwt2d]&lt;br /&gt;
&lt;br /&gt;
=Modeling=&lt;br /&gt;
All methods below deal with acoustic data, unless noted otherwise. Also, to be in the modeling section, a program/chain of programs must produce actual seismograms, not just traveltime curves. Those go into the &amp;quot;Traveltime computation&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
Programs listed below create time-domain seismic data (wavefield at z=0, i.e. hyperbolas) given a reflectivity model (wavefield at t=0 in the exploding reflector paradigm). Sometimes it is suggestive to plot &amp;quot;shots&amp;quot;, i.e. one or several wavefronts at various times. One way to do it with downward-continuation based shot-modeling algorithm is to save the whole wavefield in the time domain, then to extract the slices at the appropriate times. This can get storage-intensive, and slow as it can be IO-bound. Another way is to use a reverse-time procedure and simply save the appropriate time snapshots. This is very CPU-intensive and artifacts can easily appear. The cheapest and the most elegant way is to remember that a wavefront at time t originating from a shot is indistinguishable from the migration impulse response of a spike at time t at the same x location. So to originate a series of wavefronts at intervals dt from a shot at location x and time t, one just has to migrate a sequence of spikes separated by dt at location x. This way, any of the programs in the &amp;quot;migration&amp;quot; section can also be used to create &amp;quot;shots&amp;quot; &amp;amp;ndash; including those programs based on survey-sinking!&lt;br /&gt;
&lt;br /&gt;
==Creating reflectivity models==&lt;br /&gt;
* For linear arrivals: [http://reproducibility.org/RSF/sfspike.html spike], followed by [http://reproducibility.org/RSF/sfbandpass.html bandpass] or convolution ([http://reproducibility.org/RSF/sfconv.html conv]) with a wavelet&lt;br /&gt;
* Simple 2-D synthetics with crossing plane waves: [http://reproducibility.org/RSF/sfmake.html make]&lt;br /&gt;
* Generates the 3-D Qdome model: [http://reproducibility.org/RSF/sfqdome.html qdome]&lt;br /&gt;
* Generates the 2-D Sigmoid model: [http://reproducibility.org/RSF/sfsigmoid.html sigmoid]&lt;br /&gt;
* Generates the 2-D Synmarine model, spreads it across offsets and applies moveout: [http://reproducibility.org/RSF/sfsynmarine.html synmarine] (bandpass or convolution with a wavelet still needed)&lt;br /&gt;
* Generates the 2-D Conflicting Dips model: [http://reproducibility.org/RSF/sfconflict.html conflict]&lt;br /&gt;
* Simple synthetics with random reflectivity: [http://reproducibility.org/RSF/sfrandrefl.html randrefl]&lt;br /&gt;
&lt;br /&gt;
==Adding noise==&lt;br /&gt;
* Synthetics with bursts of noise: [http://reproducibility.org/RSF/sfburstnoise.html burstnoise]&lt;br /&gt;
* Add random noise to the data: [http://reproducibility.org/RSF/sfnoise.html noise]&lt;br /&gt;
&lt;br /&gt;
==Creating falsely irregular data==&lt;br /&gt;
* Cut an elliptic hole in data: [http://reproducibility.org/RSF/sfhole.html hole]&lt;br /&gt;
* Remove random shot gathers from a 2-D dataset: [http://reproducibility.org/RSF/sfshotholes.html shotholes]&lt;br /&gt;
&lt;br /&gt;
==Creating velocity models==&lt;br /&gt;
* Generate 2-D layered velocity model from specified interfaces: [http://reproducibility.org/RSF/sfunif2.html unif2]&lt;br /&gt;
* Generate 3-D layered velocity model from specified interfaces: [http://reproducibility.org/RSF/sfunif3.html unif3]&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, v(x,z)==&lt;br /&gt;
* Extended split step wavefield extrapolation method: [http://reproducibility.org/RSF/sfsrmod.html srmod]&lt;br /&gt;
==3-D, prestack, common-azimuth, v(x,z)==&lt;br /&gt;
* Split-step method: [http://reproducibility.org/RSF/sfcamig.html camig]&lt;br /&gt;
==3-D, prestack, v(z)==&lt;br /&gt;
* Kirchhoff method using analytical Green&#039;s functions: [http://reproducibility.org/RSF/sfkirmod3.html kirmod3]&lt;br /&gt;
==3-D, zero-offset, v(x,z)==&lt;br /&gt;
* Extended split step wavefield extrapolation method: [http://reproducibility.org/RSF/sfsstep2.html sstep2], [http://reproducibility.org/RSF/sfzomig.html zomig]&lt;br /&gt;
==3-D, zero-offset, const.v==&lt;br /&gt;
* Stolt (F-K) method: [http://reproducibility.org/RSF/sfstolt.html stolt]&lt;br /&gt;
==2.5-D, v(z)==&lt;br /&gt;
* Kirchhoff method using analytical Green&#039;s functions: [http://reproducibility.org/RSF/sfkirmod.html kirmod]&lt;br /&gt;
==2-D, prestack, v(x,z)==&lt;br /&gt;
* Unknown ray-based method: [http://reproducibility.org/RSF/sfshoot2.html shoot2]&lt;br /&gt;
* Second-order cell ray tracing with locally parabolic rays: [http://reproducibility.org/RSF/sfcell2.html cell2].&lt;br /&gt;
* Ray tracing by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2.html rays2]&lt;br /&gt;
* Time-domain acoustic FD: [http://reproducibility.org/RSF/sfafmod.html afmod], [http://reproducibility.org/RSF/sfawe.html awe], [http://reproducibility.org/RSF/sfawefd.html awefd], [http://reproducibility.org/RSF/sfawefd1.html awefd1], [http://reproducibility.org/RSF/sfafdm2d.html afdm2d]&lt;br /&gt;
* Time-domain acoustic linearized FD: [http://reproducibility.org/RSF/sflwefd.html lwefd], [http://reproducibility.org/RSF/sflwefd1.html lwefd1]&lt;br /&gt;
* DSR-based survey-continuation WE method: [http://reproducibility.org/RSF/sfdsr2.html dsr2]&lt;br /&gt;
==2-D, prestack, v(x,z), anisotropic media==&lt;br /&gt;
* Ray tracing in VTI media by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2a.html rays2a]&lt;br /&gt;
==2-D, prestack, v(z)==&lt;br /&gt;
* DSR-based survey-continuation WE method: [http://reproducibility.org/RSF/sfdsr.html dsr]&lt;br /&gt;
* [http://reproducibility.org/RSF/sfspike.html spike], [http://reproducibility.org/RSF/sfbandpass.html bandpass], [http://reproducibility.org/RSF/sfinmo.html inmo]&lt;br /&gt;
* Analytical traveltime in a linear slowness squared model: [http://reproducibility.org/RSF/sfs2ofz.html s2ofz]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, const. v==&lt;br /&gt;
* Kirchhoff: [http://reproducibility.org/RSF/sfpreconstkirch.html preconstkirch]&lt;br /&gt;
* Stolt (F-K): [http://reproducibility.org/RSF/sfprestolt.html prestolt]&lt;br /&gt;
==2-D, zero-offset, v(x,z)==&lt;br /&gt;
* Implicit finite-difference method, 15 and 45 degree approximation: [http://reproducibility.org/RSF/sfmig45.html mig45]&lt;br /&gt;
* Riemannian Wavefield Extrapolation: [http://reproducibility.org/RSF/sfrwezomig.html rwezomig]&lt;br /&gt;
==2-D, zero-offset, v(z)==&lt;br /&gt;
* Wavefield-extrapolation, phase-shift method: [http://reproducibility.org/RSF/sfgazdag.html gazdag]&lt;br /&gt;
* Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfkirchnew.html kirchnew]&lt;br /&gt;
* 1-D convolution modeling: [http://reproducibility.org/RSF/sfai2refl.html ai2refl]&lt;br /&gt;
&lt;br /&gt;
==Elastic modeling==&lt;br /&gt;
* Time-domain 2-D FD method: [http://reproducibility.org/RSF/sfewefd2d.html ewefd2d]&lt;br /&gt;
==Anisotropic modeling==&lt;br /&gt;
* Time-domain 2-D FD TTI: [http://reproducibility.org/RSF/sfewefd2dtti.html ewefd2dtti]&lt;br /&gt;
* [http://reproducibility.org/RSF/sfanifd2d.html anifd2d]&lt;br /&gt;
&lt;br /&gt;
==Unconventional outputs==&lt;br /&gt;
* Models PP intercept, PP gradient and PS gradient directly: [http://reproducibility.org/RSF/sfmodrefl2.html modrefl2]&lt;br /&gt;
* Outputs PP and PS seismograms in the tau-p domain: [http://reproducibility.org/RSF/sfmodrefl3.html modrefl3]&lt;br /&gt;
==Uncertain==&lt;br /&gt;
* [http://reproducibility.org/RSF/sfmodrefl.html modrefl] (&amp;quot;Normal reflectivity modeling&amp;quot;, according to &amp;lt;tt&amp;gt;sfdoc -k&amp;lt;/tt&amp;gt;). Takes as input files with vp, vs and rho, but it is not clear whether it outputs a 2-D or 3-D file, and if modeling is with ray or WE methods.&lt;br /&gt;
* 2-D, unknown if prestack or zero-offset, v(x,z), Born modeling: [http://reproducibility.org/RSF/sfaborn.html aborn], [http://reproducibility.org/RSF/sfborn2d.html born2d]&lt;br /&gt;
&lt;br /&gt;
=Migration=&lt;br /&gt;
&lt;br /&gt;
Below, &amp;quot;v(x,z)&amp;quot; means &amp;quot;works when the velocity has lateral velocity variations, and will try to do something about them&amp;quot;. This corresponds to what is widely called depth migration, but possibly to &amp;quot;smart&amp;quot; time migrations as well. The &amp;quot;const. v&amp;quot; term will be applied to algorithms that can only deal with constant velocity, regardless of whether the output is in depth or time. The &amp;quot;v(z)&amp;quot; term describes all other migrations. Note that the above terms apply even to migrations that do not need a velocity model!&lt;br /&gt;
&lt;br /&gt;
It is assumed that a 3-D prestack algorithm will be able to migrate a 2-D prestack or a 3-D poststack, that a v(x,z) will be able to deal with a constant-velocity case, and so on. Exceptions to these rules will be highlighted.&lt;br /&gt;
&lt;br /&gt;
The term &amp;quot;survey-sinking&amp;quot; was preferred to &amp;quot;source-receiver&amp;quot; because it can be done in either midpoint-offset, or in source-receiver coordinates, and the two differ in their treatment of amplitudes (a CMP gather is not a wavefield).&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, wide-azimuth, v(x,z)==&lt;br /&gt;
*Survey-sinking scheme in midpoint-offset coordinates with extended split-step extrapolator: [http://reproducibility.org/RSF/sfsrmig.html srmig], [http://reproducibility.org/RSF/sfsrmig2.html srmig2]&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, common-azimuth, v(x,z)==&lt;br /&gt;
*Extended split-step extrapolator: [http://reproducibility.org/RSF/sfcamig.html camig]&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, one-azimuth, const. v==&lt;br /&gt;
The &amp;quot;one-azimuth&amp;quot; term was employed to underline that they take as input 3-D data with a single offset dimension, but they do not employ the common-azimuth approximation&amp;lt;ref&amp;gt;Biondi, B., and Palacharla, G.: 3-D prestack migration of common-azimuth data, Geophysics, v. 61, pp. 1822-1832.&amp;lt;/ref&amp;gt; when computing ky.&lt;br /&gt;
*F-K scheme: [http://reproducibility.org/RSF/sfprestolt.html prestolt]&lt;br /&gt;
*Kirchhoff scheme: [http://reproducibility.org/RSF/sfpreconstkirch.html preconstkirch]&lt;br /&gt;
&lt;br /&gt;
==3-D, poststack, v(x,z)==&lt;br /&gt;
*Extended split-step extrapolator: [http://reproducibility.org/RSF/sfsstep2.html sstep2], [http://reproducibility.org/RSF/sfzomig.html zomig]&lt;br /&gt;
&lt;br /&gt;
==3-D, poststack, const. v==&lt;br /&gt;
*F-K scheme: [http://reproducibility.org/RSF/sfstolt.html stolt], with impulse response examples in &amp;lt;tt&amp;gt;sep/forwd&amp;lt;/tt&amp;gt;&lt;br /&gt;
*Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfmig3.html mig3], [http://reproducibility.org/RSF/sfmigsteep3.html migsteep3]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, v(x,z)==&lt;br /&gt;
*Survey-sinking scheme in midpoint-offset coordinates with PSPI extrapolator: [http://reproducibility.org/RSF/sfdsr.html dsr]&lt;br /&gt;
*Survey-sinking scheme in midpoint-offset coordinates with split-step extrapolator: [http://reproducibility.org/RSF/sfdsr2.html dsr2]&lt;br /&gt;
*Shot-profile scheme, Riemannian extrapolator: [http://reproducibility.org/RSF/sfrwe2d.html rwe2d], [http://reproducibility.org/RSF/sfrwesrmig.html rwesrmig]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, v(z)==&lt;br /&gt;
*Slope-based migration: [http://reproducibility.org/RSF/sfpmig.html pmig]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, const. v==&lt;br /&gt;
*Angle-gather migration: [http://reproducibility.org/RSF/sfagmig.html agmig]&lt;br /&gt;
&lt;br /&gt;
==2-D, poststack, v(x,z)==&lt;br /&gt;
*Implicit finite-difference extrapolator, 15 and 45 degree approximations: [http://reproducibility.org/RSF/sfmig45.html mig45]&lt;br /&gt;
*Riemannian extrapolator: [http://reproducibility.org/RSF/sfrwezomig.html rwezomig]&lt;br /&gt;
&lt;br /&gt;
==2-D, poststack, v(z)==&lt;br /&gt;
*Phase-shift extrapolator: [http://reproducibility.org/RSF/sfgazdag.html gazdag]&lt;br /&gt;
*Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfkirchnew.html kirchnew]&lt;br /&gt;
*Least-squares Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfkirchinv.html kirchinv]&lt;br /&gt;
&lt;br /&gt;
==2-D, poststack, const. v==&lt;br /&gt;
*Implicit finite-difference extrapolator: [http://reproducibility.org/RSF/sfconstfdmig2.html constfdmig2]&lt;br /&gt;
&lt;br /&gt;
==Migration without a velocity model==&lt;br /&gt;
*Slope-based 2-D prestack migration, works in v(z) media: [http://reproducibility.org/RSF/sfpmig.html pmig]&lt;br /&gt;
&lt;br /&gt;
==Least-squares migration==&lt;br /&gt;
*Kirchhoff, 2-D, post-stack, v(z), with antialiasing: [http://reproducibility.org/RSF/sfkirchinv.html kirchinv]&lt;br /&gt;
&lt;br /&gt;
=Image Cosmetics=&lt;br /&gt;
* Automatic gain control: [http://reproducibility.org/RSF/sfagc.html agc]&lt;br /&gt;
* Image enhancement by histogram equalization: [http://reproducibility.org/RSF/sfequal.html equal]&lt;br /&gt;
* Non-stationary spectral balancing: [http://reproducibility.org/RSF/sfreshape.html reshape]&lt;br /&gt;
&lt;br /&gt;
=Angle gathers=&lt;br /&gt;
* Transform from offset-domain common image gathers (ODCIGs) to angle-domain common image gathers: [http://reproducibility.org/RSF/sfradon.html radon], followed by arctangent stretch and conversion from radians to degrees&lt;br /&gt;
* Illustration of angle gathers: [http://reproducibility.org/RSF/sfangle.html angle]&lt;br /&gt;
* Another illustration of angle gathers: [http://reproducibility.org/RSF/sfangle2.html angle2]&lt;br /&gt;
* Transform PP angle gathers to PS angle gathers: [http://reproducibility.org/RSF/sfpp2psang2.html pp2psang2]&lt;br /&gt;
* Transform PP angle gathers to PS angle gathers: [http://reproducibility.org/RSF/sfpp2psang.html pp2psang]&lt;br /&gt;
* Compute angle gathers for time-shift imaging condition: [http://reproducibility.org/RSF/sfpp2pstsic.html pp2pstsic]&lt;br /&gt;
* Apply dip correction for angle-gathers computed with absolute offset: [http://reproducibility.org/RSF/sfabsoffdip.html absoffdip]&lt;br /&gt;
* Compute angle gathers for time-shift imaging condition: [http://reproducibility.org/RSF/sftshift.html tshift]&lt;br /&gt;
&lt;br /&gt;
=Dip estimation=&lt;br /&gt;
* Estimate a number of constant dips using plane-wave destruction: [http://reproducibility.org/RSF/sfdips.html dips]&lt;br /&gt;
* 3-D dip estimation by plane wave destruction: [http://reproducibility.org/RSF/sfdip.html dip]&lt;br /&gt;
* 2-D two dip estimation by plane wave destruction: [http://reproducibility.org/RSF/sftwodip2.html twodip2]&lt;br /&gt;
&lt;br /&gt;
=Attribute extraction=&lt;br /&gt;
* Compute intercept and gradient by least squares: [http://reproducibility.org/RSF/sfavo.html avo]&lt;br /&gt;
* Smooth estimate of instantaneous frequency: [http://reproducibility.org/RSF/sfiphase.html iphase]&lt;br /&gt;
* Canny-like edge detector: [http://reproducibility.org/RSF/sfcanny.html canny]&lt;br /&gt;
=Horizon extraction=&lt;br /&gt;
* Extract horizons from data: [http://reproducibility.org/RSF/sfhslice.html hslice]&lt;br /&gt;
* Extract a slice using picked surface (usually from a stack or a semblance): [http://reproducibility.org/RSF/sfslice.html slice]&lt;br /&gt;
&lt;br /&gt;
=Directional wavefields methods=&lt;br /&gt;
These algorithms create or use directional wavefields at the surface or in depth. The most-known variety is tau-p, aka p-tau, aka slant stack, aka Linear Radon Transform, aka plane-wave synthesis, aka delayed-shot survey generation, aka Controlled Directional Reception (CDR), aka Controlled Directional Source, aka beam forming, aka plane-wave decomposition. Various people mean various things by these terms, with some agreement that &amp;quot;slant stack&amp;quot; is reserved to more simple flavor of the operation, &amp;quot;plane-wave decomposition&amp;quot; is the more carefully thought one trying to take care of the amplitudes, and CDR refers to shorter cable lengths. The various flavors of beam methods are good cousins of these approaches.&lt;br /&gt;
* Time-space-domain slant stack with antialiasing and a rho filter: [http://reproducibility.org/RSF/sfslant.html slant]&lt;br /&gt;
* High-resolution Linear Radon Transform: [http://reproducibility.org/RSF/sfradon.html radon]. Inversion approach trying to maximize spikes in the tau-p domain, and filter out other events, including elliptical ones (you may not want to use this for creating inputs to methods that work with ellipses in the tau-p domain!)&lt;br /&gt;
* Modeling that outputs PP and PS seismograms in the tau-p domain: [http://reproducibility.org/RSF/sfmodrefl3.html modrefl3]&lt;br /&gt;
* Normal moveout in tau-p domain: [http://reproducibility.org/RSF/sftaupmo.html taupmo]&lt;br /&gt;
* Diffraction imaging in the plane-wave domain: [http://reproducibility.org/RSF/sfdimag.html dimag]&lt;br /&gt;
&lt;br /&gt;
=Transforms=&lt;br /&gt;
* Time-space-domain slant stack with antialiasing and a rho filter: [http://reproducibility.org/RSF/sfslant.html slant]&lt;br /&gt;
* High-resolution Linear Radon Transform: [http://reproducibility.org/RSF/sfradon.html radon]. Inversion approach trying to maximize spikes in the tau-p domain, and filter out other events, including elliptical ones (you may not want to use this for creating inputs to methods that work with ellipses in the tau-p domain!)&lt;br /&gt;
* Parabolic Radon Transform: [http://reproducibility.org/RSF/sfradon.html radon] with &amp;lt;tt&amp;gt;parab=y&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Hyperbolic Radon Transform: [http://reproducibility.org/RSF/sfveltran.html veltran]&lt;br /&gt;
* Hyperbolic Radon Transform with conjugate-directions inversion: [http://reproducibility.org/RSF/sfcgscan.html cgscan]&lt;br /&gt;
* Phase-space Radon transform: [http://reproducibility.org/RSF/sfpradon.html pradon]&lt;br /&gt;
* Radial Transform: [http://reproducibility.org/RSF/sfradial.html radial]&lt;br /&gt;
* FFT along the first axis: [http://reproducibility.org/RSF/sffft1.html fft1]&lt;br /&gt;
* FFT: [http://reproducibility.org/RSF/sffft3.html fft3]&lt;br /&gt;
* Frequency spectra: [http://reproducibility.org/RSF/sfspectra.html spectra]&lt;br /&gt;
* Frequency spectra in 2-D: [http://reproducibility.org/RSF/sfspectra2.html spectra2]&lt;br /&gt;
* 1-D Digital Wavelet Transform: [http://reproducibility.org/RSF/sfdwt.html dwt]&lt;br /&gt;
* Multi-dimensional cosine transform: [http://reproducibility.org/RSF/sfcosft.html cosft]&lt;br /&gt;
* Seislet transform: [http://reproducibility.org/RSF/sfseislet.html seislet]&lt;br /&gt;
* Freqlet transform: [http://reproducibility.org/RSF/sffreqlet.html freqlet]&lt;br /&gt;
&lt;br /&gt;
=Smoothers and rougheners=&lt;br /&gt;
* 2-D smoothing by triangle plane-wave construction shaping: [http://reproducibility.org/RSF/sfpwdsmooth2.html pwdsmooth2]&lt;br /&gt;
* Recursive Gaussian smoothing on the fast axis: [http://reproducibility.org/RSF/sfgaussmooth.html gaussmooth]&lt;br /&gt;
* Smooth first derivative on the first axis: [http://reproducibility.org/RSF/sfsmoothder.html smoothder]&lt;br /&gt;
* Multi-dimensional triangle smoothing: [http://reproducibility.org/RSF/sfsmooth.html smooth]&lt;br /&gt;
* Smoothing in 2-D by simple regularization: [http://reproducibility.org/RSF/sfsmoothreg2.html smoothreg2]&lt;br /&gt;
* Smoothing in 1-D by simple regularization: [http://reproducibility.org/RSF/sfsmoothreg.html smoothreg]&lt;br /&gt;
* First derivative with a maximally linear FIR differentiator: [http://reproducibility.org/RSF/sfderiv.html deriv]&lt;br /&gt;
* 2-D smooth gradient: [http://reproducibility.org/RSF/sfgrad2.html grad2]&lt;br /&gt;
* Gradient on the first axis: [http://reproducibility.org/RSF/sfigrad.html igrad]&lt;br /&gt;
* Apply 2-D directional high-pass to highlight data: [http://reproducibility.org/RSF/sflight.html light]&lt;br /&gt;
* 1-D non-stationary smoothing: [http://reproducibility.org/RSF/sfnsmooth1.html nsmooth1]&lt;br /&gt;
* N-D non-stationary smoothing: [http://reproducibility.org/RSF/sfnsmooth.html nsmooth]&lt;br /&gt;
* Multi-dimensional smoothing with boxes: [http://reproducibility.org/RSF/sfboxsmooth.html boxsmooth]&lt;br /&gt;
* Half-order integration or differentiation: [http://reproducibility.org/RSF/sfhalfint.html halfint]&lt;br /&gt;
* 2-D smoothing by triangle directional shaping: [http://reproducibility.org/RSF/sftrismooth2.html trismooth2]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Programs yet to be classified=&lt;br /&gt;
* [http://reproducibility.org/RSF/sfaliasp.html aliasp]: Aliasing test&lt;br /&gt;
* [http://reproducibility.org/RSF/sfapprox.html approx]: Illustrating non-hyperbolic approximations &lt;br /&gt;
* [http://reproducibility.org/RSF/sfautocorr.html autocorr]: Autocorrelation for helix filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfcflow.html cflow]: Fast mean-curvature flow&lt;br /&gt;
* [http://reproducibility.org/RSF/sfcostaper.html costaper]: Cosine taper around the borders (N-D)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfcube2list.html cube2list]: Maps a cube to a list, given a threshold (clip value)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfdeblur.html deblur]: Non-stationary debluring by inversion &lt;br /&gt;
* [http://reproducibility.org/RSF/sfdijkstra.html dijkstra]: Dijkstra shortest-path algorithm in 2-D &lt;br /&gt;
* [http://reproducibility.org/RSF/sfdiplet.html diplet]: Seislet frame&lt;br /&gt;
* [http://reproducibility.org/RSF/sfdistance.html distance]: Computing distance function by fast marching eikonal solver (3-D) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfdivn.html divn]: Smooth division&lt;br /&gt;
* [http://reproducibility.org/RSF/sfeikonal.html eikonal]: Fast marching eikonal solver (3-D)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfeikonalvti.html eikonalvti]: Fast marching eikonal solver in VTI media&lt;br /&gt;
* [http://reproducibility.org/RSF/sferfdm.html erfdm]&lt;br /&gt;
* [http://reproducibility.org/RSF/sfexgr.html exgr]: Exact group velocity in VTI media &lt;br /&gt;
* [http://reproducibility.org/RSF/sfextract.html extract]: Forward interpolation in 2-D slices&lt;br /&gt;
* [http://reproducibility.org/RSF/sfflat3.html flat3]: 3-D flattening (without picking)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfflat.html flat]: Moveout flattening&lt;br /&gt;
* [http://reproducibility.org/RSF/sffocus.html focus]: Focusing indicator&lt;br /&gt;
* [http://reproducibility.org/RSF/sfframe.html frame]: Create a frame for binning&lt;br /&gt;
* [http://reproducibility.org/RSF/sffreqest.html freqest]: Local frequency estimation &lt;br /&gt;
* [http://reproducibility.org/RSF/sfgreen.html green]: Phase-space Green&#039;s function from down-marching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfhconv.html hconv]: Convolution of two helix filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfhelicon.html helicon]: Multidimensional convolution and deconvolution by helix transform&lt;br /&gt;
* [http://reproducibility.org/RSF/sfic.html ic]: Imaging condition &lt;br /&gt;
* [http://reproducibility.org/RSF/sficor.html icor]: Interferometric cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfidempatch.html idempatch]: Patching test&lt;br /&gt;
* [http://reproducibility.org/RSF/sfimpl1.html impl1]: 1-D anisotropic diffusion&lt;br /&gt;
* [http://reproducibility.org/RSF/sfimpl2.html impl2]: 2-D anisotropic diffusion&lt;br /&gt;
* [http://reproducibility.org/RSF/sfimpl3.html impl3]: 3-D anisotropic diffusion&lt;br /&gt;
* [http://reproducibility.org/RSF/sfinterp2.html interp2]: Multiple-arrival interpolation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfinterp3.html interp3]: Multiple-arrival interpolation from down-marching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfinterpt.html interpt]: Multiple-arrival interpolation (yet another)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfintshow.html intshow]: Output interpolation filter&lt;br /&gt;
* [http://reproducibility.org/RSF/sfkolmog.html kolmog]: Kolmogoroff spectral factorization&lt;br /&gt;
* [http://reproducibility.org/RSF/sflaps.html laps]: Compute lagged-products &lt;br /&gt;
* [http://reproducibility.org/RSF/sflinefit.html linefit]: Fit a line to a set of points in 2-D&lt;br /&gt;
* [http://reproducibility.org/RSF/sflopef.html lopef]: Local Prediction-Error Filter (1-D, 2-D, and 3-D)&lt;br /&gt;
* [http://reproducibility.org/RSF/sflpef.html lpef]: Find PEF on aliased traces&lt;br /&gt;
* [http://reproducibility.org/RSF/sflpf.html lpf]: Local prefiction filter (n-dimensional)&lt;br /&gt;
* [http://reproducibility.org/RSF/sflstk.html lstk]: Local slant stacks (2D) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfmspef.html mspef]: Multi-scale PEF estimation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfnhelicon.html nhelicon]: Non-stationary helix convolution and deconvolution&lt;br /&gt;
* [http://reproducibility.org/RSF/sfnpef.html npef]: Estimate Non-stationary PEF in N dimensions&lt;br /&gt;
* [http://reproducibility.org/RSF/sfocparcel.html ocparcel]: Patching test for out-of-core patching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfoctentwt.html octentwt]: Tent-like weight for out-of-core patching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfoff2abs3.html off2abs3]: Transform vector-offset to absolute-offset &lt;br /&gt;
* [http://reproducibility.org/RSF/sfoff2abs.html off2abs]: Transform vector-offset to absolute-offset &lt;br /&gt;
* [http://reproducibility.org/RSF/sfofpwd2.html ofpwd2]: Objective function of two dips estimation with PWD filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfofpwd.html ofpwd]: Objective function of dip estimation with PWD filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfofsemb.html ofsemb]: Objective function of dip estimation with semblance&lt;br /&gt;
* [http://reproducibility.org/RSF/sfparcel.html parcel]: Patching test&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpatch.html patch]: Patching (N-dimensional)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpef.html pef]: Multi-dimensional PEF (prediction error filter) estimation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpostfilter2.html postfilter2]: Convert B-spline coefficients to data in 2-D&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpredict.html predict]: 2-D plane-wave prediction&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpwd.html pwd]: 3-D plane wave destruction&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpwdsigk.html pwdsigk]: Signal component separation using plane-wave destruction&lt;br /&gt;
* [http://reproducibility.org/RSF/sfrefer.html refer]: Subtract a reference from a grid&lt;br /&gt;
* [http://reproducibility.org/RSF/sfreg2tri.html reg2tri]: Decimate a regular grid to triplets for triangulation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfricker1.html ricker1]: Convolution with a Ricker wavelet&lt;br /&gt;
* [http://reproducibility.org/RSF/sfrweab.html rweab]: Riemannian Wavefield Extrapolation]:* a,b coefficients &lt;br /&gt;
* [http://reproducibility.org/RSF/sfrwemete2d.html rwemete2d]: 2-D metric tensor &lt;br /&gt;
* [http://reproducibility.org/RSF/sfseisigk.html seisigk]: Signal component separation using seislet transforms&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshapebin1.html shapebin1]: 1-D inverse interpolation with shaping regularization&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshapebin.html shapebin]: Data binning in 2-D slices by inverse interpolation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshapesigk.html shapesigk]: Signal component separation using plane-wave shaping&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshotprop.html shotprop]: Shot propagation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfsic3d.html sic3d]: Local slant stacks IC&lt;br /&gt;
* [http://reproducibility.org/RSF/sfsic.html sic]: Local slant stacks IC&lt;br /&gt;
* [http://reproducibility.org/RSF/sfsplinebank.html splinebank]: Prepare a filter bank for B-spline plane wave filters &lt;br /&gt;
* [http://reproducibility.org/RSF/sfsplinefilter.html splinefilter]: Convert data to B-spline coefficients &lt;br /&gt;
* [http://reproducibility.org/RSF/sfsrsyn.html srsyn]: Synthesize shot/receiver wavefields for 3-D SR migration &lt;br /&gt;
* [http://reproducibility.org/RSF/sftan2ang.html tan2ang]: Compute cos(theta) from 1/|pm| for time-shift imaging condition &lt;br /&gt;
* [http://reproducibility.org/RSF/sftcor.html tcor]: Interferometric cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sftentwt.html tentwt]: Tent-like weight for patching&lt;br /&gt;
* [http://reproducibility.org/RSF/sftimeshift.html timeshift]: Apply variable time shifts using plane-wave construction&lt;br /&gt;
* [http://reproducibility.org/RSF/sftrapez.html trapez]: Convolution with a trapezoidal filter&lt;br /&gt;
* [http://reproducibility.org/RSF/sftree.html tree]: Multiple arrivals with a fast algorithm&lt;br /&gt;
* [http://reproducibility.org/RSF/sftri2reg.html tri2reg]: Interpolate triangulated triplets to a regular grid&lt;br /&gt;
* [http://reproducibility.org/RSF/sftrirand.html trirand]: Edit points for triangulation by removing similar and randomizing&lt;br /&gt;
* [http://reproducibility.org/RSF/sftspline.html tspline]: Helix filters for spline in tension &lt;br /&gt;
* [http://reproducibility.org/RSF/sftwofreq2.html twofreq2]: 2-D two spectral component estimation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfucor.html ucor]: Interferometric cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfwarp1.html warp1]: Multicomponent data registration by 1-D warping&lt;br /&gt;
* [http://reproducibility.org/RSF/sfwarpadd.html warpadd]: Add a perturbation to the warping function&lt;br /&gt;
* [http://reproducibility.org/RSF/sfwarpscan.html warpscan]: Multicomponent data registration analysis&lt;br /&gt;
* [http://reproducibility.org/RSF/sfwdf.html wdf]: Assymptotic Wigner distribution &lt;br /&gt;
* [http://reproducibility.org/RSF/sfwigner.html wigner]: Assymptotic Wigner distribution in space-time &lt;br /&gt;
* [http://reproducibility.org/RSF/sfwilson.html wilson]: Wilson-Burg spectral factorization&lt;br /&gt;
* [http://reproducibility.org/RSF/sfxcor.html xcor]: Cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfztrace.html ztrace]: Multiple arrivals by depth marching&lt;br /&gt;
* The SCons macros in &amp;lt;tt&amp;gt;RSFSRC/book/packages&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=NM_task-centric_program_program_list&amp;diff=1978</id>
		<title>NM task-centric program program list</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=NM_task-centric_program_program_list&amp;diff=1978"/>
		<updated>2011-08-06T16:28:27Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Multi-file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of &#039;&#039;&#039;Numerical Methods&#039;&#039;&#039; programs in Madagascar. An overview of all task-centric pages can be found in the main [[Task-centric program list]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;All program names below should be prefixed with &amp;quot;sf&amp;quot;.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Operation on file content ==&lt;br /&gt;
&lt;br /&gt;
*  Generate simple data (spikes, boxes, planes, constants): [http://reproducibility.org/RSF/sfspike.html spike]&lt;br /&gt;
* Mathematical operations on data files: [http://reproducibility.org/RSF/sfmath.html math]&lt;br /&gt;
* Add, multiply, or divide  RSF datasets: [http://reproducibility.org/RSF/sfadd.html add]&lt;br /&gt;
* Add, multiply, or divide  RSF datasets (fast, OMP-enabled): [http://reproducibility.org/RSF/sfparadd.html paradd]&lt;br /&gt;
* Create a mask: [http://reproducibility.org/RSF/sfmask.html mask]&lt;br /&gt;
* Scale data: [http://reproducibility.org/RSF/sfscale.html scale]&lt;br /&gt;
* Rotate a portion of one or more axes in the data hypercube: [http://reproducibility.org/RSF/sfrotate.html rotate]&lt;br /&gt;
* Zero a portion of the dataset: [http://reproducibility.org/RSF/sfcut.html cut]&lt;br /&gt;
* Extend a dataset by duplicating in the specified axis dimension: [http://reproducibility.org/RSF/sfspray.html spray]&lt;br /&gt;
&lt;br /&gt;
==Complex number operations==&lt;br /&gt;
* Convert real data to complex (by adding zero imaginary part): [http://reproducibility.org/RSF/sfrtoc.html rtoc]&lt;br /&gt;
* Extract real part of a complex dataset: [http://reproducibility.org/RSF/sfreal.html real]&lt;br /&gt;
* Extract imaginary part of a complex dataset: [http://reproducibility.org/RSF/sfreal.html imag]&lt;br /&gt;
* Create a complex dataset from its real and imaginary parts: [http://reproducibility.org/RSF/sfcmplx.html cmplx]&lt;br /&gt;
&lt;br /&gt;
=Statistical operations on files=&lt;br /&gt;
==Single-file==&lt;br /&gt;
* Display dataset attributes: [http://reproducibility.org/RSF/sfattr.html attr]&lt;br /&gt;
* 1-D histogram: [http://reproducibility.org/RSF/sfhistogram.html histogram]&lt;br /&gt;
* Computes what clip value corresponds to a given pclip: [http://reproducibility.org/RSF/sfquantile.html quantile]&lt;br /&gt;
* Clip the data: [http://reproducibility.org/RSF/sfclip.html clip]&lt;br /&gt;
* One- or two-sided data clipping: [http://reproducibility.org/RSF/sfclip2.html clip2]&lt;br /&gt;
* Percentile clip: [http://reproducibility.org/RSF/sfpclip.html pclip]&lt;br /&gt;
* Threshold float/complex inputs given a constant/varying threshold level: [http://reproducibility.org/RSF/sfthr.html thr]&lt;br /&gt;
* Soft thresholding: [http://reproducibility.org/RSF/sfthreshold.html threshold]&lt;br /&gt;
* Construct incremental minimum or maximum lists from an RSF file: [http://reproducibility.org/RSF/sflistminmax.html listminmax]&lt;br /&gt;
* Sort a float/complex vector by absolute values: [http://reproducibility.org/RSF/sfsort.html sort]&lt;br /&gt;
&lt;br /&gt;
==Multi-file==&lt;br /&gt;
* Element by element minimum or maximum of two RSF files: [http://reproducibility.org/RSF/sfminmax.html minmax]&lt;br /&gt;
* Similarity measure between two datasets: [http://reproducibility.org/RSF/sfsimilarity.html similarity]&lt;br /&gt;
* 2-D histogram (inputs from 2 files): [http://reproducibility.org/RSF/sfhist2.html hist2]&lt;br /&gt;
&lt;br /&gt;
= Mathematics algorithms =&lt;br /&gt;
&lt;br /&gt;
==Basic mathematical processes==&lt;br /&gt;
&lt;br /&gt;
* Causal integration on the first axis: [http://reproducibility.org/RSF/sfcausint.html causint]&lt;br /&gt;
* Derivative along the first axis: [http://reproducibility.org/RSF/sfigrad.html igrad]&lt;br /&gt;
* Fast Fourier Transform along the first axis (from real to complex): [http://reproducibility.org/RSF/sffft1.html fft1]&lt;br /&gt;
* FFT transform on extra axis (from complex to complex): [http://reproducibility.org/RSF/sffft1.html fft3]&lt;br /&gt;
* 3D FFT with centering and Hermitian scaling: [http://reproducibility.org/RSF/sffft1.html fft3d]&lt;br /&gt;
* Frequency spectra: [http://reproducibility.org/RSF/sfspectra.html spectra]&lt;br /&gt;
* Frequency spectra in 2-D: [http://reproducibility.org/RSF/sfspectra2.html spectra2]&lt;br /&gt;
* 1-D Digital Wavelet Transform: [http://reproducibility.org/RSF/sfdwt.html dwt]&lt;br /&gt;
* Multi-dimensional cosine transform: [http://reproducibility.org/RSF/sfcosft.html cosft]&lt;br /&gt;
&lt;br /&gt;
==Linear Algebra==&lt;br /&gt;
&lt;br /&gt;
* Simple matrix multiplication: [http://reproducibility.org/RSF/sfmatmult.html matmult]&lt;br /&gt;
* Simple matrix multiplication for complex matrices: [http://reproducibility.org/RSF/sfcmatmult.html cmatmult]&lt;br /&gt;
* Find eigenvalues and eigenvectors of a symmetric positive definite matrix: [http://reproducibility.org/RSF/sfdmeig.html dmeig]&lt;br /&gt;
* Kroneker product with square matrices: [http://reproducibility.org/RSF/sfkron.html kron]&lt;br /&gt;
* Generic conjugate-gradient solver for linear inversion: [http://reproducibility.org/RSF/sfconjgrad.html conjgrad]&lt;br /&gt;
* Generic dot-product test for linear operators with adjoints: [http://reproducibility.org/RSF/sfdottest.html dottest]&lt;br /&gt;
* Generic conjugate-gradient solver for linear inversion with complex data: [http://reproducibility.org/RSF/sfcconjgrad.html cconjgrad]&lt;br /&gt;
* Generic dot-product test for complex linear operators with adjoints: [http://reproducibility.org/RSF/sfcdottest.html cdottest]&lt;br /&gt;
* Stack a dataset over one of the dimensions: [http://reproducibility.org/RSF/sfstack.html stack]&lt;br /&gt;
* Transpose two axes in a dataset: [http://reproducibility.org/RSF/sftransp.html transp]&lt;br /&gt;
&lt;br /&gt;
== Interpolation ==&lt;br /&gt;
* 1-D ENO (Essentiallly Non Oscillatory) interpolation: [http://reproducibility.org/RSF/sfremap1.html remap1]&lt;br /&gt;
* 1-D sinc interpolation: [http://reproducibility.org/RSF/sfsinc.html sinc]&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=NM_task-centric_program_program_list&amp;diff=1977</id>
		<title>NM task-centric program program list</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=NM_task-centric_program_program_list&amp;diff=1977"/>
		<updated>2011-08-06T16:28:01Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Single-file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;List of &#039;&#039;&#039;Numerical Methods&#039;&#039;&#039; programs in Madagascar. An overview of all task-centric pages can be found in the main [[Task-centric program list]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;All program names below should be prefixed with &amp;quot;sf&amp;quot;.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Operation on file content ==&lt;br /&gt;
&lt;br /&gt;
*  Generate simple data (spikes, boxes, planes, constants): [http://reproducibility.org/RSF/sfspike.html spike]&lt;br /&gt;
* Mathematical operations on data files: [http://reproducibility.org/RSF/sfmath.html math]&lt;br /&gt;
* Add, multiply, or divide  RSF datasets: [http://reproducibility.org/RSF/sfadd.html add]&lt;br /&gt;
* Add, multiply, or divide  RSF datasets (fast, OMP-enabled): [http://reproducibility.org/RSF/sfparadd.html paradd]&lt;br /&gt;
* Create a mask: [http://reproducibility.org/RSF/sfmask.html mask]&lt;br /&gt;
* Scale data: [http://reproducibility.org/RSF/sfscale.html scale]&lt;br /&gt;
* Rotate a portion of one or more axes in the data hypercube: [http://reproducibility.org/RSF/sfrotate.html rotate]&lt;br /&gt;
* Zero a portion of the dataset: [http://reproducibility.org/RSF/sfcut.html cut]&lt;br /&gt;
* Extend a dataset by duplicating in the specified axis dimension: [http://reproducibility.org/RSF/sfspray.html spray]&lt;br /&gt;
&lt;br /&gt;
==Complex number operations==&lt;br /&gt;
* Convert real data to complex (by adding zero imaginary part): [http://reproducibility.org/RSF/sfrtoc.html rtoc]&lt;br /&gt;
* Extract real part of a complex dataset: [http://reproducibility.org/RSF/sfreal.html real]&lt;br /&gt;
* Extract imaginary part of a complex dataset: [http://reproducibility.org/RSF/sfreal.html imag]&lt;br /&gt;
* Create a complex dataset from its real and imaginary parts: [http://reproducibility.org/RSF/sfcmplx.html cmplx]&lt;br /&gt;
&lt;br /&gt;
=Statistical operations on files=&lt;br /&gt;
==Single-file==&lt;br /&gt;
* Display dataset attributes: [http://reproducibility.org/RSF/sfattr.html attr]&lt;br /&gt;
* 1-D histogram: [http://reproducibility.org/RSF/sfhistogram.html histogram]&lt;br /&gt;
* Computes what clip value corresponds to a given pclip: [http://reproducibility.org/RSF/sfquantile.html quantile]&lt;br /&gt;
* Clip the data: [http://reproducibility.org/RSF/sfclip.html clip]&lt;br /&gt;
* One- or two-sided data clipping: [http://reproducibility.org/RSF/sfclip2.html clip2]&lt;br /&gt;
* Percentile clip: [http://reproducibility.org/RSF/sfpclip.html pclip]&lt;br /&gt;
* Threshold float/complex inputs given a constant/varying threshold level: [http://reproducibility.org/RSF/sfthr.html thr]&lt;br /&gt;
* Soft thresholding: [http://reproducibility.org/RSF/sfthreshold.html threshold]&lt;br /&gt;
* Construct incremental minimum or maximum lists from an RSF file: [http://reproducibility.org/RSF/sflistminmax.html listminmax]&lt;br /&gt;
* Sort a float/complex vector by absolute values: [http://reproducibility.org/RSF/sfsort.html sort]&lt;br /&gt;
&lt;br /&gt;
==Multi-file==&lt;br /&gt;
* Element by element minimum or maximum of two RSF files: [http://reproducibility.org/RSF/sfminmax.html minmax]&lt;br /&gt;
* Similarity measure between two datasets: [http://reproducibility.org/RSF/sfsimilarity.html similarity]&lt;br /&gt;
&lt;br /&gt;
= Mathematics algorithms =&lt;br /&gt;
&lt;br /&gt;
==Basic mathematical processes==&lt;br /&gt;
&lt;br /&gt;
* Causal integration on the first axis: [http://reproducibility.org/RSF/sfcausint.html causint]&lt;br /&gt;
* Derivative along the first axis: [http://reproducibility.org/RSF/sfigrad.html igrad]&lt;br /&gt;
* Fast Fourier Transform along the first axis (from real to complex): [http://reproducibility.org/RSF/sffft1.html fft1]&lt;br /&gt;
* FFT transform on extra axis (from complex to complex): [http://reproducibility.org/RSF/sffft1.html fft3]&lt;br /&gt;
* 3D FFT with centering and Hermitian scaling: [http://reproducibility.org/RSF/sffft1.html fft3d]&lt;br /&gt;
* Frequency spectra: [http://reproducibility.org/RSF/sfspectra.html spectra]&lt;br /&gt;
* Frequency spectra in 2-D: [http://reproducibility.org/RSF/sfspectra2.html spectra2]&lt;br /&gt;
* 1-D Digital Wavelet Transform: [http://reproducibility.org/RSF/sfdwt.html dwt]&lt;br /&gt;
* Multi-dimensional cosine transform: [http://reproducibility.org/RSF/sfcosft.html cosft]&lt;br /&gt;
&lt;br /&gt;
==Linear Algebra==&lt;br /&gt;
&lt;br /&gt;
* Simple matrix multiplication: [http://reproducibility.org/RSF/sfmatmult.html matmult]&lt;br /&gt;
* Simple matrix multiplication for complex matrices: [http://reproducibility.org/RSF/sfcmatmult.html cmatmult]&lt;br /&gt;
* Find eigenvalues and eigenvectors of a symmetric positive definite matrix: [http://reproducibility.org/RSF/sfdmeig.html dmeig]&lt;br /&gt;
* Kroneker product with square matrices: [http://reproducibility.org/RSF/sfkron.html kron]&lt;br /&gt;
* Generic conjugate-gradient solver for linear inversion: [http://reproducibility.org/RSF/sfconjgrad.html conjgrad]&lt;br /&gt;
* Generic dot-product test for linear operators with adjoints: [http://reproducibility.org/RSF/sfdottest.html dottest]&lt;br /&gt;
* Generic conjugate-gradient solver for linear inversion with complex data: [http://reproducibility.org/RSF/sfcconjgrad.html cconjgrad]&lt;br /&gt;
* Generic dot-product test for complex linear operators with adjoints: [http://reproducibility.org/RSF/sfcdottest.html cdottest]&lt;br /&gt;
* Stack a dataset over one of the dimensions: [http://reproducibility.org/RSF/sfstack.html stack]&lt;br /&gt;
* Transpose two axes in a dataset: [http://reproducibility.org/RSF/sftransp.html transp]&lt;br /&gt;
&lt;br /&gt;
== Interpolation ==&lt;br /&gt;
* 1-D ENO (Essentiallly Non Oscillatory) interpolation: [http://reproducibility.org/RSF/sfremap1.html remap1]&lt;br /&gt;
* 1-D sinc interpolation: [http://reproducibility.org/RSF/sfsinc.html sinc]&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Seismic_task-centric_program_list&amp;diff=1976</id>
		<title>Seismic task-centric program list</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Seismic_task-centric_program_list&amp;diff=1976"/>
		<updated>2011-08-06T16:25:00Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Manipulating irregular datasets, regularization and sorting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_369804_XS.jpg|right|]]&lt;br /&gt;
This page presents a list of programs for seismic processing, imaging and analysis. An overview of all task-centric pages can be found in the main [[Task-centric program list]].&lt;br /&gt;
&lt;br /&gt;
The most frequent question encountered from a new user is: &amp;quot;Does Madagascar do [some needed process]?&amp;quot; The first level of classification is therefore by types of geophysical procedures. Then the classifications below try to follow&#039;s the user&#039;s workflow:&lt;br /&gt;
# What sort of data must be processed/imaged: 3-D, 2-D, prestack, poststack?&lt;br /&gt;
# If a velocity model is needed, which sort is available? A v(x,z) one, a v(z) or a constant velocity?&lt;br /&gt;
# Which algorithm to use if several are available.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;All program names below should be prefixed with &amp;quot;sf&amp;quot;.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=Manipulating irregular datasets, regularization and sorting=&lt;br /&gt;
* Integer header attributes: [http://reproducibility.org/RSF/sfheaderattr.html headerattr]&lt;br /&gt;
* Zero a portion of a dataset based on a header mask: [http://reproducibility.org/RSF/sfheadercut.html headercut]&lt;br /&gt;
* Mathematical operations, possibly on header keys: [http://reproducibility.org/RSF/sfheadermath.html headermath]&lt;br /&gt;
* Sort a dataset according to a header key: [http://reproducibility.org/RSF/sfheadersort.html headersort]&lt;br /&gt;
* Window a dataset based on a header mask: [http://reproducibility.org/RSF/sfheaderwindow.html headerwindow]&lt;br /&gt;
* Create a mask: [http://reproducibility.org/RSF/sfmask.html mask]&lt;br /&gt;
* Shot interpolation: [http://reproducibility.org/RSF/sfinfill.html infill]&lt;br /&gt;
* Data binning (geometry regularization): [http://reproducibility.org/RSF/sfintbin.html intbin] (works especially for basically regular geometries but with skipped or resorted traces)&lt;br /&gt;
* Data binning in 1-D slices: [http://reproducibility.org/RSF/sfbin1.html bin1]&lt;br /&gt;
* Data binning in 2-D slices: [http://reproducibility.org/RSF/sfbin.html bin]&lt;br /&gt;
* Data regularization in 2-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanereg2.html planereg2]&lt;br /&gt;
* Data regularization in 3-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanereg3.html planereg3]&lt;br /&gt;
* Convert CMPs to shots for regular 2-D geometry: [http://reproducibility.org/RSF/sfcmp2shot.html cmp2shot]&lt;br /&gt;
* Convert shots to CMPs for regular 2-D geometry: [http://reproducibility.org/RSF/sfshot2cmp.html shot2cmp]&lt;br /&gt;
* 2-D fold maps: [http://ahay.org/RSF/sfhist2.html hist2]&lt;br /&gt;
&lt;br /&gt;
=Interpolation tools=&lt;br /&gt;
==Making holes==&lt;br /&gt;
* Cut an elliptic hole in data (for interpolation tests): [http://reproducibility.org/RSF/sfhole.html hole]&lt;br /&gt;
* Create a synthetic irregular dataset for interpolation tests: [http://reproducibility.org/RSF/sfsyntop.html syntop]&lt;br /&gt;
==Actual interpolation==&lt;br /&gt;
* Linear interpolation: [http://reproducibility.org/RSF/sflint1.html lint1]&lt;br /&gt;
* 1-D cubic spline interpolation: [http://reproducibility.org/RSF/sfspline.html spline]&lt;br /&gt;
* Data interpolation in 2-D slices using helix preconditioning: [http://reproducibility.org/RSF/sfinvbin.html invbin]&lt;br /&gt;
* 1-D inverse interpolation: [http://reproducibility.org/RSF/sfinvbin1.html invbin1]&lt;br /&gt;
* Leveler inverse interpolation in 1-D: [http://reproducibility.org/RSF/sflevint.html levint]&lt;br /&gt;
* Find MISSing Input values and Filter in 1-D: [http://reproducibility.org/RSF/sfmisif.html misif]&lt;br /&gt;
* Missing data interpolation in 1-D: [http://reproducibility.org/RSF/sfmiss1.html miss1]&lt;br /&gt;
* 2-D missing data interpolation: [http://reproducibility.org/RSF/sfmiss2.html miss2]&lt;br /&gt;
* Missing data interpolation (N-dimensional) using shaping regularization: [http://reproducibility.org/RSF/sfmiss3.html miss3]&lt;br /&gt;
* Multi-dimensional missing data interpolation: [http://reproducibility.org/RSF/sfmiss.html miss]&lt;br /&gt;
* Multiscale missing data interpolation (N-dimensional): [http://reproducibility.org/RSF/sfmsmiss.html msmiss]&lt;br /&gt;
* 2-D missing data interpolation by differential offset continuation: [http://reproducibility.org/RSF/sfofilp.html ofilp]&lt;br /&gt;
* 1-D ENO (Essentially Non Oscillatory) interpolation: [http://reproducibility.org/RSF/sfremap1.html remap1]&lt;br /&gt;
* ENO interpolation in 2-D slices: [http://reproducibility.org/RSF/sfenoint2.html enoint2]&lt;br /&gt;
* 2-D trace interpolation to a denser grid using PWD (&amp;quot;beyond aliasing&amp;quot; method): [http://reproducibility.org/RSF/sfdealias.html dealias]&lt;br /&gt;
* Shot interpolation: [http://reproducibility.org/RSF/sfinfill.html infill]&lt;br /&gt;
* Testing forward interpolation in 1-D: [http://reproducibility.org/RSF/sfinttest1.html inttest1]&lt;br /&gt;
* Testing forward interpolation in 2-D: [http://reproducibility.org/RSF/sfinttest2.html inttest2]&lt;br /&gt;
* Missing data interpolation in 2-D by Laplacian regularization: [http://reproducibility.org/RSF/sflapfill.html lapfill]&lt;br /&gt;
* Missing data interpolation using one or two prediction-error filters: [http://reproducibility.org/RSF/sfmaskinv.html maskinv]&lt;br /&gt;
* Missing data interpolation in 2-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanemis2.html planemis2]&lt;br /&gt;
* Missing data interpolation in 3-D using plane-wave destruction: [http://reproducibility.org/RSF/sfplanemis3.html planemis3]&lt;br /&gt;
* Missing data interpolation in 2-D using plane-wave destruction and shaping regularization: [http://reproducibility.org/RSF/sfpmshape2.html pmshape2]&lt;br /&gt;
&lt;br /&gt;
=Classic preprocessing=&lt;br /&gt;
Excludes: (1) denoising; (2) moveouts/stretches, and (3) interpolations, which will get their own sections.&lt;br /&gt;
* Stretch of the time axis:  [[Guide_to_madagascar_programs#sfstretch | stretch guide]], [http://reproducibility.org/RSF/sfstretch.html stretch]&lt;br /&gt;
* Amplitude balancing: [http://reproducibility.org/RSF/sfabalance.html abalance]&lt;br /&gt;
* Compute data envelope: [http://reproducibility.org/RSF/sfenvelope.html envelope]&lt;br /&gt;
* Automatic gain control: [http://reproducibility.org/RSF/sfagc.html agc]&lt;br /&gt;
* Bandpass filtering: [http://reproducibility.org/RSF/sfbandpass.html bandpass]&lt;br /&gt;
* Bandpass filtering using erf function: [http://reproducibility.org/RSF/sferf.html erf]&lt;br /&gt;
* Deconvolution (N-dimensional): [http://reproducibility.org/RSF/sfdecon.html decon]&lt;br /&gt;
* 1-D convolution: [http://reproducibility.org/RSF/sfconv.html conv]&lt;br /&gt;
* Dip filtering (2-D or 3-D): [http://reproducibility.org/RSF/sfdipfilter.html dipfilter]&lt;br /&gt;
* Muting: [http://reproducibility.org/RSF/sfmutter.html mutter]&lt;br /&gt;
* Stack a dataset over one of the dimensions: [http://reproducibility.org/RSF/sfstack.html stack]&lt;br /&gt;
* Time power gain: [http://reproducibility.org/RSF/sftpow.html tpow]&lt;br /&gt;
* Frequency spectra: [http://reproducibility.org/RSF/sfspectra.html spectra]&lt;br /&gt;
* Frequency spectra in 2-D: [http://reproducibility.org/RSF/sfspectra2.html spectra2]&lt;br /&gt;
* Static correction: [http://reproducibility.org/RSF/sfstretch.html datstretch]. Use the the &amp;lt;tt&amp;gt;datum=&amp;lt;/tt&amp;gt; parameter to specify file holding time shifts.&lt;br /&gt;
&lt;br /&gt;
=Wavelet estimation=&lt;br /&gt;
* Mono-frequency wavelet estimation: [http://reproducibility.org/RSF/sfmonof.html monof]&lt;br /&gt;
* Gaussian wavelet estimation in 2-D: [http://reproducibility.org/RSF/sfmonof2.html monof2]&lt;br /&gt;
* Ricker wavelet estimation: [http://reproducibility.org/RSF/sfricker.html ricker]&lt;br /&gt;
&lt;br /&gt;
=Denoising/S-N separation=&lt;br /&gt;
* Denoising using stationary wavelet transform: [http://reproducibility.org/RSF/sfswtdenoise.html swtdenoise]&lt;br /&gt;
* Remove bursty noise by IRLS: [http://reproducibility.org/RSF/sfdeburst.html deburst]&lt;br /&gt;
* Burst noise removal using PEF: [http://reproducibility.org/RSF/sfpefdeburst.html pefdeburst]&lt;br /&gt;
* Remove spikes in by sliding 1-D medians: [http://reproducibility.org/RSF/sfdespike.html despike]&lt;br /&gt;
* Remove spikes in by sliding 2-D medians: [http://reproducibility.org/RSF/sfdespike2.html despike2]&lt;br /&gt;
* Remove spikes in by sliding 3-D medians: [http://reproducibility.org/RSF/sfdespike3.html despike3]&lt;br /&gt;
* Signal and noise separation (N-dimensional): [http://reproducibility.org/RSF/sfsignoi.html signoi]&lt;br /&gt;
* Local signal and noise separation (N-dimensional): [http://reproducibility.org/RSF/sflosignoi.html losignoi]&lt;br /&gt;
* Signal and noise separation using plane-wave destruction filters: [http://reproducibility.org/RSF/sfplanesignoi.html planesignoi]&lt;br /&gt;
* Signal and noise separation using both frequency components and dips: [http://reproducibility.org/RSF/sfexplanesignoi.html explanesignoi]&lt;br /&gt;
* Signal and noise separation using frequency components: [http://reproducibility.org/RSF/sfexpsignoi.html expsignoi]&lt;br /&gt;
&lt;br /&gt;
=Tracewise stretch/moveout operators=&lt;br /&gt;
These operators do not carry energy from one trace to the other. The operation can be performed independently on each trace.&lt;br /&gt;
* General stretch of the time axis: [http://reproducibility.org/RSF/sfstretch.html stretch]&lt;br /&gt;
* Constant-velocity Normal Moveout stretch: [http://reproducibility.org/RSF/sfstretch.html nmostretch]&lt;br /&gt;
* Linear Moveout stretch: [http://reproducibility.org/RSF/sfstretch.html lmostretch]&lt;br /&gt;
* Log stretch: [http://reproducibility.org/RSF/sfstretch.html logstretch]&lt;br /&gt;
* T-square stretch: [http://reproducibility.org/RSF/sfstretch.html t2stretch]&lt;br /&gt;
* T-square Chebyshev stretch: [http://reproducibility.org/RSF/sfstretch.html t2chebstretch]&lt;br /&gt;
* Radial moveout: [http://reproducibility.org/RSF/sfstretch.html radstretch]&lt;br /&gt;
* Datuming stretch: [http://reproducibility.org/RSF/sfstretch.html datstretch]&lt;br /&gt;
* Normal moveout: [http://reproducibility.org/RSF/sfnmo.html nmo]&lt;br /&gt;
* Inverse normal moveout: [http://reproducibility.org/RSF/sfinmo.html inmo]&lt;br /&gt;
* Constant-velocity nearest-neighbor inverse NMO: [http://reproducibility.org/RSF/sfimospray.html imospray]&lt;br /&gt;
* Normal moveout in tau-p domain: [http://reproducibility.org/RSF/sftaupmo.html taupmo]&lt;br /&gt;
* Slope-based normal moveout: [http://reproducibility.org/RSF/sfpnmo.html pnmo]&lt;br /&gt;
&lt;br /&gt;
=DMO/AMO/Offset continuation=&lt;br /&gt;
* Kirchhoff DMO with antialiasing by reparameterization: [http://reproducibility.org/RSF/sfdmo.html dmo]&lt;br /&gt;
* Azimuth moveout by log-stretch F-K operator: [http://reproducibility.org/RSF/sffkamo.html fkamo]&lt;br /&gt;
* Offset continuation by log-stretch F-K operator: [http://reproducibility.org/RSF/sffkdmo.html fkdmo]&lt;br /&gt;
* Offset continuation by finite differences: [http://reproducibility.org/RSF/sffincon.html fincon]&lt;br /&gt;
* DMO and stack by finite-difference offset continuation: [http://reproducibility.org/RSF/sffinstack.html finstack]&lt;br /&gt;
&lt;br /&gt;
=Whole-image stretching=&lt;br /&gt;
* Stolt stretch: [http://reproducibility.org/RSF/sfstoltstretch.html stoltstretch]&lt;br /&gt;
* Cartesian-Coordinates to Riemannian-Coordinates interpolation: [http://reproducibility.org/RSF/sfc2r.html c2r]&lt;br /&gt;
&lt;br /&gt;
=Autopicking=&lt;br /&gt;
* Automatic picking from semblance-like panels: [http://reproducibility.org/RSF/sfpick.html pick], [http://reproducibility.org/RSF/sfpick2.html pick2]&lt;br /&gt;
* Generate stereopicks from time-migration velocities and slopes: [http://reproducibility.org/RSF/sfpgen.html pgen]&lt;br /&gt;
* Generate stereotomography picks from time migration: [http://reproducibility.org/RSF/sfspicks.html spicks]&lt;br /&gt;
* Picking local maxima on the first axis: [http://reproducibility.org/RSF/sfmax1.html max1]&lt;br /&gt;
* Picking by plane-wave construction: [http://reproducibility.org/RSF/sfpwpick.html pwpick]&lt;br /&gt;
* Preconditioning for traveltime picking: [http://reproducibility.org/RSF/sfshearer.html shearer]&lt;br /&gt;
&lt;br /&gt;
=Velocity analysis=&lt;br /&gt;
* Velocity transform: [http://reproducibility.org/RSF/sfvelmod.html velmod]&lt;br /&gt;
* Slope-based velocity transform: [http://reproducibility.org/RSF/sfpveltran.html pveltran]&lt;br /&gt;
* Hyperbolic Radon transform: [http://reproducibility.org/RSF/sfveltran.html veltran]&lt;br /&gt;
* Hyperbolic Radon transform with conjugate-directions inversion: [http://reproducibility.org/RSF/sfcgscan.html cgscan]&lt;br /&gt;
* Velocity analysis: [http://reproducibility.org/RSF/sfvscan.html vscan]&lt;br /&gt;
* 3-D zero-offset WEMVA: [http://reproducibility.org/RSF/sfzomva.html zomva]&lt;br /&gt;
* 3-D S/R WEMVA with extended split-step: [http://reproducibility.org/RSF/sfsrmva.html srmva]&lt;br /&gt;
* Simple tomography test: [http://reproducibility.org/RSF/sftomo.html tomo]&lt;br /&gt;
&lt;br /&gt;
=Velocity continuation=&lt;br /&gt;
* Post-stack 2-D velocity continuation by Chebyshev-tau method: [http://reproducibility.org/RSF/sfchebvc.html chebvc]&lt;br /&gt;
* Velocity continuation: [http://reproducibility.org/RSF/sffourvc.html fourvc]&lt;br /&gt;
* Velocity continuation after NMO: [http://reproducibility.org/RSF/sffourvc0.html fourvc0]&lt;br /&gt;
* Velocity continuation with semblance computation: [http://reproducibility.org/RSF/sffourvc2.html fourvc2]&lt;br /&gt;
* Post-stack velocity continuation by implicit finite differences: [http://reproducibility.org/RSF/sfvelcon.html velcon]&lt;br /&gt;
* 3-D finite-difference velocity continuation on a helix: [http://reproducibility.org/RSF/sfvelcon3.html velcon3]&lt;br /&gt;
&lt;br /&gt;
=Velocity and data converters=&lt;br /&gt;
* Convert RMS to interval velocity: [http://reproducibility.org/RSF/sfdix.html dix]&lt;br /&gt;
* Convert RMS to interval velocity using LS and shaping regularization: [http://reproducibility.org/RSF/sfdixshape.html dixshape]&lt;br /&gt;
* V(t) function for a linear V(Z) profile: [http://reproducibility.org/RSF/sfvoft.html voft]&lt;br /&gt;
* Conversion from depth to time in a V(z) medium: [http://reproducibility.org/RSF/sfdepth2time.html depth2time]&lt;br /&gt;
* Time-to-depth conversion in V(z): [http://reproducibility.org/RSF/sftime2depth.html time2depth]&lt;br /&gt;
* Convert RMS to interval velocity using LS and plane-wave construction: [http://reproducibility.org/RSF/sfpwdix.html pwdix]&lt;br /&gt;
&lt;br /&gt;
=Ray tracing=&lt;br /&gt;
The programs below take as input a velocity model and output ray trajectories.&lt;br /&gt;
==2-D, v(x,z)==&lt;br /&gt;
* Huygens wavefront tracing: [http://reproducibility.org/RSF/sfhwt2d.html hwt2d]&lt;br /&gt;
* For layered media: [http://reproducibility.org/RSF/sflayer.html layer]&lt;br /&gt;
* Second-order cell ray tracing with locally parabolic rays: [http://reproducibility.org/RSF/sfcell2.html cell2].&lt;br /&gt;
* Ray tracing by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2.html rays2]&lt;br /&gt;
==2-D, v(x,z), anisotropic media==&lt;br /&gt;
* Ray tracing in VTI media by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2a.html rays2a]&lt;br /&gt;
==2-D, v(x,z), multiples==&lt;br /&gt;
* By cell ray tracing: [http://reproducibility.org/RSF/sftrace2.html trace2]&lt;br /&gt;
&lt;br /&gt;
== Plotting ==&lt;br /&gt;
&lt;br /&gt;
* Plot rays: [http://reproducibility.org/RSF/sfplotrays.html plotrays]&lt;br /&gt;
* Plot rays in 3D with OpenGL: [http://reproducibility.org/RSF/sfplotrays3.html plotsray3]&lt;br /&gt;
&lt;br /&gt;
=Traveltimes computation=&lt;br /&gt;
* Analytical traveltime in 2-D, linear v(z): [http://reproducibility.org/RSF/sfvofz.html vofz]&lt;br /&gt;
* Huygens wavefront tracing (ray-based method): [http://reproducibility.org/RSF/sfhwtex.html hwtex], [http://reproducibility.org/RSF/sfhwt2d.html hwt2d]&lt;br /&gt;
&lt;br /&gt;
=Modeling=&lt;br /&gt;
All methods below deal with acoustic data, unless noted otherwise. Also, to be in the modeling section, a program/chain of programs must produce actual seismograms, not just traveltime curves. Those go into the &amp;quot;Traveltime computation&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
Programs listed below create time-domain seismic data (wavefield at z=0, i.e. hyperbolas) given a reflectivity model (wavefield at t=0 in the exploding reflector paradigm). Sometimes it is suggestive to plot &amp;quot;shots&amp;quot;, i.e. one or several wavefronts at various times. One way to do it with downward-continuation based shot-modeling algorithm is to save the whole wavefield in the time domain, then to extract the slices at the appropriate times. This can get storage-intensive, and slow as it can be IO-bound. Another way is to use a reverse-time procedure and simply save the appropriate time snapshots. This is very CPU-intensive and artifacts can easily appear. The cheapest and the most elegant way is to remember that a wavefront at time t originating from a shot is indistinguishable from the migration impulse response of a spike at time t at the same x location. So to originate a series of wavefronts at intervals dt from a shot at location x and time t, one just has to migrate a sequence of spikes separated by dt at location x. This way, any of the programs in the &amp;quot;migration&amp;quot; section can also be used to create &amp;quot;shots&amp;quot; &amp;amp;ndash; including those programs based on survey-sinking!&lt;br /&gt;
&lt;br /&gt;
==Creating reflectivity models==&lt;br /&gt;
* For linear arrivals: [http://reproducibility.org/RSF/sfspike.html spike], followed by [http://reproducibility.org/RSF/sfbandpass.html bandpass] or convolution ([http://reproducibility.org/RSF/sfconv.html conv]) with a wavelet&lt;br /&gt;
* Simple 2-D synthetics with crossing plane waves: [http://reproducibility.org/RSF/sfmake.html make]&lt;br /&gt;
* Generates the 3-D Qdome model: [http://reproducibility.org/RSF/sfqdome.html qdome]&lt;br /&gt;
* Generates the 2-D Sigmoid model: [http://reproducibility.org/RSF/sfsigmoid.html sigmoid]&lt;br /&gt;
* Generates the 2-D Synmarine model, spreads it across offsets and applies moveout: [http://reproducibility.org/RSF/sfsynmarine.html synmarine] (bandpass or convolution with a wavelet still needed)&lt;br /&gt;
* Generates the 2-D Conflicting Dips model: [http://reproducibility.org/RSF/sfconflict.html conflict]&lt;br /&gt;
* Simple synthetics with random reflectivity: [http://reproducibility.org/RSF/sfrandrefl.html randrefl]&lt;br /&gt;
&lt;br /&gt;
==Adding noise==&lt;br /&gt;
* Synthetics with bursts of noise: [http://reproducibility.org/RSF/sfburstnoise.html burstnoise]&lt;br /&gt;
* Add random noise to the data: [http://reproducibility.org/RSF/sfnoise.html noise]&lt;br /&gt;
&lt;br /&gt;
==Creating falsely irregular data==&lt;br /&gt;
* Cut an elliptic hole in data: [http://reproducibility.org/RSF/sfhole.html hole]&lt;br /&gt;
* Remove random shot gathers from a 2-D dataset: [http://reproducibility.org/RSF/sfshotholes.html shotholes]&lt;br /&gt;
&lt;br /&gt;
==Creating velocity models==&lt;br /&gt;
* Generate 2-D layered velocity model from specified interfaces: [http://reproducibility.org/RSF/sfunif2.html unif2]&lt;br /&gt;
* Generate 3-D layered velocity model from specified interfaces: [http://reproducibility.org/RSF/sfunif3.html unif3]&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, v(x,z)==&lt;br /&gt;
* Extended split step wavefield extrapolation method: [http://reproducibility.org/RSF/sfsrmod.html srmod]&lt;br /&gt;
==3-D, prestack, common-azimuth, v(x,z)==&lt;br /&gt;
* Split-step method: [http://reproducibility.org/RSF/sfcamig.html camig]&lt;br /&gt;
==3-D, prestack, v(z)==&lt;br /&gt;
* Kirchhoff method using analytical Green&#039;s functions: [http://reproducibility.org/RSF/sfkirmod3.html kirmod3]&lt;br /&gt;
==3-D, zero-offset, v(x,z)==&lt;br /&gt;
* Extended split step wavefield extrapolation method: [http://reproducibility.org/RSF/sfsstep2.html sstep2], [http://reproducibility.org/RSF/sfzomig.html zomig]&lt;br /&gt;
==3-D, zero-offset, const.v==&lt;br /&gt;
* Stolt (F-K) method: [http://reproducibility.org/RSF/sfstolt.html stolt]&lt;br /&gt;
==2.5-D, v(z)==&lt;br /&gt;
* Kirchhoff method using analytical Green&#039;s functions: [http://reproducibility.org/RSF/sfkirmod.html kirmod]&lt;br /&gt;
==2-D, prestack, v(x,z)==&lt;br /&gt;
* Unknown ray-based method: [http://reproducibility.org/RSF/sfshoot2.html shoot2]&lt;br /&gt;
* Second-order cell ray tracing with locally parabolic rays: [http://reproducibility.org/RSF/sfcell2.html cell2].&lt;br /&gt;
* Ray tracing by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2.html rays2]&lt;br /&gt;
* Time-domain acoustic FD: [http://reproducibility.org/RSF/sfafmod.html afmod], [http://reproducibility.org/RSF/sfawe.html awe], [http://reproducibility.org/RSF/sfawefd.html awefd], [http://reproducibility.org/RSF/sfawefd1.html awefd1], [http://reproducibility.org/RSF/sfafdm2d.html afdm2d]&lt;br /&gt;
* Time-domain acoustic linearized FD: [http://reproducibility.org/RSF/sflwefd.html lwefd], [http://reproducibility.org/RSF/sflwefd1.html lwefd1]&lt;br /&gt;
* DSR-based survey-continuation WE method: [http://reproducibility.org/RSF/sfdsr2.html dsr2]&lt;br /&gt;
==2-D, prestack, v(x,z), anisotropic media==&lt;br /&gt;
* Ray tracing in VTI media by a Runge-Kutta integrator: [http://reproducibility.org/RSF/sfrays2a.html rays2a]&lt;br /&gt;
==2-D, prestack, v(z)==&lt;br /&gt;
* DSR-based survey-continuation WE method: [http://reproducibility.org/RSF/sfdsr.html dsr]&lt;br /&gt;
* [http://reproducibility.org/RSF/sfspike.html spike], [http://reproducibility.org/RSF/sfbandpass.html bandpass], [http://reproducibility.org/RSF/sfinmo.html inmo]&lt;br /&gt;
* Analytical traveltime in a linear slowness squared model: [http://reproducibility.org/RSF/sfs2ofz.html s2ofz]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, const. v==&lt;br /&gt;
* Kirchhoff: [http://reproducibility.org/RSF/sfpreconstkirch.html preconstkirch]&lt;br /&gt;
* Stolt (F-K): [http://reproducibility.org/RSF/sfprestolt.html prestolt]&lt;br /&gt;
==2-D, zero-offset, v(x,z)==&lt;br /&gt;
* Implicit finite-difference method, 15 and 45 degree approximation: [http://reproducibility.org/RSF/sfmig45.html mig45]&lt;br /&gt;
* Riemannian Wavefield Extrapolation: [http://reproducibility.org/RSF/sfrwezomig.html rwezomig]&lt;br /&gt;
==2-D, zero-offset, v(z)==&lt;br /&gt;
* Wavefield-extrapolation, phase-shift method: [http://reproducibility.org/RSF/sfgazdag.html gazdag]&lt;br /&gt;
* Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfkirchnew.html kirchnew]&lt;br /&gt;
* 1-D convolution modeling: [http://reproducibility.org/RSF/sfai2refl.html ai2refl]&lt;br /&gt;
&lt;br /&gt;
==Elastic modeling==&lt;br /&gt;
* Time-domain FD method: [http://reproducibility.org/RSF/sfewefd.html ewefd]&lt;br /&gt;
==Unconventional outputs==&lt;br /&gt;
* Models PP intercept, PP gradient and PS gradient directly: [http://reproducibility.org/RSF/sfmodrefl2.html modrefl2]&lt;br /&gt;
* Outputs PP and PS seismograms in the tau-p domain: [http://reproducibility.org/RSF/sfmodrefl3.html modrefl3]&lt;br /&gt;
==Uncertain==&lt;br /&gt;
* [http://reproducibility.org/RSF/sfmodrefl.html modrefl] (&amp;quot;Normal reflectivity modeling&amp;quot;, according to &amp;lt;tt&amp;gt;sfdoc -k&amp;lt;/tt&amp;gt;). Takes as input files with vp, vs and rho, but it is not clear whether it outputs a 2-D or 3-D file, and if modeling is with ray or WE methods.&lt;br /&gt;
* 2-D, unknown if prestack or zero-offset, v(x,z), Born modeling: [http://reproducibility.org/RSF/sfaborn.html aborn], [http://reproducibility.org/RSF/sfborn2d.html born2d]&lt;br /&gt;
&lt;br /&gt;
=Migration=&lt;br /&gt;
&lt;br /&gt;
Below, &amp;quot;v(x,z)&amp;quot; means &amp;quot;works when the velocity has lateral velocity variations, and will try to do something about them&amp;quot;. This corresponds to what is widely called depth migration, but possibly to &amp;quot;smart&amp;quot; time migrations as well. The &amp;quot;const. v&amp;quot; term will be applied to algorithms that can only deal with constant velocity, regardless of whether the output is in depth or time. The &amp;quot;v(z)&amp;quot; term describes all other migrations. Note that the above terms apply even to migrations that do not need a velocity model!&lt;br /&gt;
&lt;br /&gt;
It is assumed that a 3-D prestack algorithm will be able to migrate a 2-D prestack or a 3-D poststack, that a v(x,z) will be able to deal with a constant-velocity case, and so on. Exceptions to these rules will be highlighted.&lt;br /&gt;
&lt;br /&gt;
The term &amp;quot;survey-sinking&amp;quot; was preferred to &amp;quot;source-receiver&amp;quot; because it can be done in either midpoint-offset, or in source-receiver coordinates, and the two differ in their treatment of amplitudes (a CMP gather is not a wavefield).&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, wide-azimuth, v(x,z)==&lt;br /&gt;
*Survey-sinking scheme in midpoint-offset coordinates with extended split-step extrapolator: [http://reproducibility.org/RSF/sfsrmig.html srmig], [http://reproducibility.org/RSF/sfsrmig2.html srmig2]&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, common-azimuth, v(x,z)==&lt;br /&gt;
*Extended split-step extrapolator: [http://reproducibility.org/RSF/sfcamig.html camig]&lt;br /&gt;
&lt;br /&gt;
==3-D, prestack, one-azimuth, const. v==&lt;br /&gt;
The &amp;quot;one-azimuth&amp;quot; term was employed to underline that they take as input 3-D data with a single offset dimension, but they do not employ the common-azimuth approximation&amp;lt;ref&amp;gt;Biondi, B., and Palacharla, G.: 3-D prestack migration of common-azimuth data, Geophysics, v. 61, pp. 1822-1832.&amp;lt;/ref&amp;gt; when computing ky.&lt;br /&gt;
*F-K scheme: [http://reproducibility.org/RSF/sfprestolt.html prestolt]&lt;br /&gt;
*Kirchhoff scheme: [http://reproducibility.org/RSF/sfpreconstkirch.html preconstkirch]&lt;br /&gt;
&lt;br /&gt;
==3-D, poststack, v(x,z)==&lt;br /&gt;
*Extended split-step extrapolator: [http://reproducibility.org/RSF/sfsstep2.html sstep2], [http://reproducibility.org/RSF/sfzomig.html zomig]&lt;br /&gt;
&lt;br /&gt;
==3-D, poststack, const. v==&lt;br /&gt;
*F-K scheme: [http://reproducibility.org/RSF/sfstolt.html stolt], with impulse response examples in &amp;lt;tt&amp;gt;sep/forwd&amp;lt;/tt&amp;gt;&lt;br /&gt;
*Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfmig3.html mig3], [http://reproducibility.org/RSF/sfmigsteep3.html migsteep3]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, v(x,z)==&lt;br /&gt;
*Survey-sinking scheme in midpoint-offset coordinates with PSPI extrapolator: [http://reproducibility.org/RSF/sfdsr.html dsr]&lt;br /&gt;
*Survey-sinking scheme in midpoint-offset coordinates with split-step extrapolator: [http://reproducibility.org/RSF/sfdsr2.html dsr2]&lt;br /&gt;
*Shot-profile scheme, Riemannian extrapolator: [http://reproducibility.org/RSF/sfrwe2d.html rwe2d], [http://reproducibility.org/RSF/sfrwesrmig.html rwesrmig]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, v(z)==&lt;br /&gt;
*Slope-based migration: [http://reproducibility.org/RSF/sfpmig.html pmig]&lt;br /&gt;
&lt;br /&gt;
==2-D, prestack, const. v==&lt;br /&gt;
*Angle-gather migration: [http://reproducibility.org/RSF/sfagmig.html agmig]&lt;br /&gt;
&lt;br /&gt;
==2-D, poststack, v(x,z)==&lt;br /&gt;
*Implicit finite-difference extrapolator, 15 and 45 degree approximations: [http://reproducibility.org/RSF/sfmig45.html mig45]&lt;br /&gt;
*Riemannian extrapolator: [http://reproducibility.org/RSF/sfrwezomig.html rwezomig]&lt;br /&gt;
&lt;br /&gt;
==2-D, poststack, v(z)==&lt;br /&gt;
*Phase-shift extrapolator: [http://reproducibility.org/RSF/sfgazdag.html gazdag]&lt;br /&gt;
*Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfkirchnew.html kirchnew]&lt;br /&gt;
*Least-squares Kirchhoff with antialiasing: [http://reproducibility.org/RSF/sfkirchinv.html kirchinv]&lt;br /&gt;
&lt;br /&gt;
==2-D, poststack, const. v==&lt;br /&gt;
*Implicit finite-difference extrapolator: [http://reproducibility.org/RSF/sfconstfdmig2.html constfdmig2]&lt;br /&gt;
&lt;br /&gt;
==Migration without a velocity model==&lt;br /&gt;
*Slope-based 2-D prestack migration, works in v(z) media: [http://reproducibility.org/RSF/sfpmig.html pmig]&lt;br /&gt;
&lt;br /&gt;
==Least-squares migration==&lt;br /&gt;
*Kirchhoff, 2-D, post-stack, v(z), with antialiasing: [http://reproducibility.org/RSF/sfkirchinv.html kirchinv]&lt;br /&gt;
&lt;br /&gt;
=Image Cosmetics=&lt;br /&gt;
* Automatic gain control: [http://reproducibility.org/RSF/sfagc.html agc]&lt;br /&gt;
* Image enhancement by histogram equalization: [http://reproducibility.org/RSF/sfequal.html equal]&lt;br /&gt;
* Non-stationary spectral balancing: [http://reproducibility.org/RSF/sfreshape.html reshape]&lt;br /&gt;
&lt;br /&gt;
=Angle gathers=&lt;br /&gt;
* Transform from offset-domain common image gathers (ODCIGs) to angle-domain common image gathers: [http://reproducibility.org/RSF/sfradon.html radon], followed by arctangent stretch and conversion from radians to degrees&lt;br /&gt;
* Illustration of angle gathers: [http://reproducibility.org/RSF/sfangle.html angle]&lt;br /&gt;
* Another illustration of angle gathers: [http://reproducibility.org/RSF/sfangle2.html angle2]&lt;br /&gt;
* Transform PP angle gathers to PS angle gathers: [http://reproducibility.org/RSF/sfpp2psang2.html pp2psang2]&lt;br /&gt;
* Transform PP angle gathers to PS angle gathers: [http://reproducibility.org/RSF/sfpp2psang.html pp2psang]&lt;br /&gt;
* Compute angle gathers for time-shift imaging condition: [http://reproducibility.org/RSF/sfpp2pstsic.html pp2pstsic]&lt;br /&gt;
* Apply dip correction for angle-gathers computed with absolute offset: [http://reproducibility.org/RSF/sfabsoffdip.html absoffdip]&lt;br /&gt;
* Compute angle gathers for time-shift imaging condition: [http://reproducibility.org/RSF/sftshift.html tshift]&lt;br /&gt;
&lt;br /&gt;
=Dip estimation=&lt;br /&gt;
* Estimate a number of constant dips using plane-wave destruction: [http://reproducibility.org/RSF/sfdips.html dips]&lt;br /&gt;
* 3-D dip estimation by plane wave destruction: [http://reproducibility.org/RSF/sfdip.html dip]&lt;br /&gt;
* 2-D two dip estimation by plane wave destruction: [http://reproducibility.org/RSF/sftwodip2.html twodip2]&lt;br /&gt;
&lt;br /&gt;
=Attribute extraction=&lt;br /&gt;
* Compute intercept and gradient by least squares: [http://reproducibility.org/RSF/sfavo.html avo]&lt;br /&gt;
* Smooth estimate of instantaneous frequency: [http://reproducibility.org/RSF/sfiphase.html iphase]&lt;br /&gt;
* Canny-like edge detector: [http://reproducibility.org/RSF/sfcanny.html canny]&lt;br /&gt;
=Horizon extraction=&lt;br /&gt;
* Extract horizons from data: [http://reproducibility.org/RSF/sfhslice.html hslice]&lt;br /&gt;
* Extract a slice using picked surface (usually from a stack or a semblance): [http://reproducibility.org/RSF/sfslice.html slice]&lt;br /&gt;
&lt;br /&gt;
=Directional wavefields methods=&lt;br /&gt;
These algorithms create or use directional wavefields at the surface or in depth. The most-known variety is tau-p, aka p-tau, aka slant stack, aka Linear Radon Transform, aka plane-wave synthesis, aka delayed-shot survey generation, aka Controlled Directional Reception (CDR), aka Controlled Directional Source, aka beam forming, aka plane-wave decomposition. Various people mean various things by these terms, with some agreement that &amp;quot;slant stack&amp;quot; is reserved to more simple flavor of the operation, &amp;quot;plane-wave decomposition&amp;quot; is the more carefully thought one trying to take care of the amplitudes, and CDR refers to shorter cable lengths. The various flavors of beam methods are good cousins of these approaches.&lt;br /&gt;
* Time-space-domain slant stack with antialiasing and a rho filter: [http://reproducibility.org/RSF/sfslant.html slant]&lt;br /&gt;
* High-resolution Linear Radon Transform: [http://reproducibility.org/RSF/sfradon.html radon]. Inversion approach trying to maximize spikes in the tau-p domain, and filter out other events, including elliptical ones (you may not want to use this for creating inputs to methods that work with ellipses in the tau-p domain!)&lt;br /&gt;
* Modeling that outputs PP and PS seismograms in the tau-p domain: [http://reproducibility.org/RSF/sfmodrefl3.html modrefl3]&lt;br /&gt;
* Normal moveout in tau-p domain: [http://reproducibility.org/RSF/sftaupmo.html taupmo]&lt;br /&gt;
* Diffraction imaging in the plane-wave domain: [http://reproducibility.org/RSF/sfdimag.html dimag]&lt;br /&gt;
&lt;br /&gt;
=Transforms=&lt;br /&gt;
* Time-space-domain slant stack with antialiasing and a rho filter: [http://reproducibility.org/RSF/sfslant.html slant]&lt;br /&gt;
* High-resolution Linear Radon Transform: [http://reproducibility.org/RSF/sfradon.html radon]. Inversion approach trying to maximize spikes in the tau-p domain, and filter out other events, including elliptical ones (you may not want to use this for creating inputs to methods that work with ellipses in the tau-p domain!)&lt;br /&gt;
* Parabolic Radon Transform: [http://reproducibility.org/RSF/sfradon.html radon] with &amp;lt;tt&amp;gt;parab=y&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Hyperbolic Radon Transform: [http://reproducibility.org/RSF/sfveltran.html veltran]&lt;br /&gt;
* Hyperbolic Radon Transform with conjugate-directions inversion: [http://reproducibility.org/RSF/sfcgscan.html cgscan]&lt;br /&gt;
* Phase-space Radon transform: [http://reproducibility.org/RSF/sfpradon.html pradon]&lt;br /&gt;
* Radial Transform: [http://reproducibility.org/RSF/sfradial.html radial]&lt;br /&gt;
* FFT along the first axis: [http://reproducibility.org/RSF/sffft1.html fft1]&lt;br /&gt;
* FFT: [http://reproducibility.org/RSF/sffft3.html fft3]&lt;br /&gt;
* Frequency spectra: [http://reproducibility.org/RSF/sfspectra.html spectra]&lt;br /&gt;
* Frequency spectra in 2-D: [http://reproducibility.org/RSF/sfspectra2.html spectra2]&lt;br /&gt;
* 1-D Digital Wavelet Transform: [http://reproducibility.org/RSF/sfdwt.html dwt]&lt;br /&gt;
* Multi-dimensional cosine transform: [http://reproducibility.org/RSF/sfcosft.html cosft]&lt;br /&gt;
* Seislet transform: [http://reproducibility.org/RSF/sfseislet.html seislet]&lt;br /&gt;
* Freqlet transform: [http://reproducibility.org/RSF/sffreqlet.html freqlet]&lt;br /&gt;
&lt;br /&gt;
=Smoothers and rougheners=&lt;br /&gt;
* 2-D smoothing by triangle plane-wave construction shaping: [http://reproducibility.org/RSF/sfpwdsmooth2.html pwdsmooth2]&lt;br /&gt;
* Recursive Gaussian smoothing on the fast axis: [http://reproducibility.org/RSF/sfgaussmooth.html gaussmooth]&lt;br /&gt;
* Smooth first derivative on the first axis: [http://reproducibility.org/RSF/sfsmoothder.html smoothder]&lt;br /&gt;
* Multi-dimensional triangle smoothing: [http://reproducibility.org/RSF/sfsmooth.html smooth]&lt;br /&gt;
* Smoothing in 2-D by simple regularization: [http://reproducibility.org/RSF/sfsmoothreg2.html smoothreg2]&lt;br /&gt;
* Smoothing in 1-D by simple regularization: [http://reproducibility.org/RSF/sfsmoothreg.html smoothreg]&lt;br /&gt;
* First derivative with a maximally linear FIR differentiator: [http://reproducibility.org/RSF/sfderiv.html deriv]&lt;br /&gt;
* 2-D smooth gradient: [http://reproducibility.org/RSF/sfgrad2.html grad2]&lt;br /&gt;
* Gradient on the first axis: [http://reproducibility.org/RSF/sfigrad.html igrad]&lt;br /&gt;
* Apply 2-D directional high-pass to highlight data: [http://reproducibility.org/RSF/sflight.html light]&lt;br /&gt;
* 1-D non-stationary smoothing: [http://reproducibility.org/RSF/sfnsmooth1.html nsmooth1]&lt;br /&gt;
* N-D non-stationary smoothing: [http://reproducibility.org/RSF/sfnsmooth.html nsmooth]&lt;br /&gt;
* Multi-dimensional smoothing with boxes: [http://reproducibility.org/RSF/sfboxsmooth.html boxsmooth]&lt;br /&gt;
* Half-order integration or differentiation: [http://reproducibility.org/RSF/sfhalfint.html halfint]&lt;br /&gt;
* 2-D smoothing by triangle directional shaping: [http://reproducibility.org/RSF/sftrismooth2.html trismooth2]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Programs yet to be classified=&lt;br /&gt;
* [http://reproducibility.org/RSF/sfaliasp.html aliasp]: Aliasing test&lt;br /&gt;
* [http://reproducibility.org/RSF/sfapprox.html approx]: Illustrating non-hyperbolic approximations &lt;br /&gt;
* [http://reproducibility.org/RSF/sfautocorr.html autocorr]: Autocorrelation for helix filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfcflow.html cflow]: Fast mean-curvature flow&lt;br /&gt;
* [http://reproducibility.org/RSF/sfcostaper.html costaper]: Cosine taper around the borders (N-D)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfcube2list.html cube2list]: Maps a cube to a list, given a threshold (clip value)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfdeblur.html deblur]: Non-stationary debluring by inversion &lt;br /&gt;
* [http://reproducibility.org/RSF/sfdijkstra.html dijkstra]: Dijkstra shortest-path algorithm in 2-D &lt;br /&gt;
* [http://reproducibility.org/RSF/sfdiplet.html diplet]: Seislet frame&lt;br /&gt;
* [http://reproducibility.org/RSF/sfdistance.html distance]: Computing distance function by fast marching eikonal solver (3-D) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfdivn.html divn]: Smooth division&lt;br /&gt;
* [http://reproducibility.org/RSF/sfeikonal.html eikonal]: Fast marching eikonal solver (3-D)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfeikonalvti.html eikonalvti]: Fast marching eikonal solver in VTI media&lt;br /&gt;
* [http://reproducibility.org/RSF/sferfdm.html erfdm]&lt;br /&gt;
* [http://reproducibility.org/RSF/sfexgr.html exgr]: Exact group velocity in VTI media &lt;br /&gt;
* [http://reproducibility.org/RSF/sfextract.html extract]: Forward interpolation in 2-D slices&lt;br /&gt;
* [http://reproducibility.org/RSF/sfflat3.html flat3]: 3-D flattening (without picking)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfflat.html flat]: Moveout flattening&lt;br /&gt;
* [http://reproducibility.org/RSF/sffocus.html focus]: Focusing indicator&lt;br /&gt;
* [http://reproducibility.org/RSF/sfframe.html frame]: Create a frame for binning&lt;br /&gt;
* [http://reproducibility.org/RSF/sffreqest.html freqest]: Local frequency estimation &lt;br /&gt;
* [http://reproducibility.org/RSF/sfgreen.html green]: Phase-space Green&#039;s function from down-marching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfhconv.html hconv]: Convolution of two helix filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfhelicon.html helicon]: Multidimensional convolution and deconvolution by helix transform&lt;br /&gt;
* [http://reproducibility.org/RSF/sfic.html ic]: Imaging condition &lt;br /&gt;
* [http://reproducibility.org/RSF/sficor.html icor]: Interferometric cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfidempatch.html idempatch]: Patching test&lt;br /&gt;
* [http://reproducibility.org/RSF/sfimpl1.html impl1]: 1-D anisotropic diffusion&lt;br /&gt;
* [http://reproducibility.org/RSF/sfimpl2.html impl2]: 2-D anisotropic diffusion&lt;br /&gt;
* [http://reproducibility.org/RSF/sfimpl3.html impl3]: 3-D anisotropic diffusion&lt;br /&gt;
* [http://reproducibility.org/RSF/sfinterp2.html interp2]: Multiple-arrival interpolation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfinterp3.html interp3]: Multiple-arrival interpolation from down-marching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfinterpt.html interpt]: Multiple-arrival interpolation (yet another)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfintshow.html intshow]: Output interpolation filter&lt;br /&gt;
* [http://reproducibility.org/RSF/sfkolmog.html kolmog]: Kolmogoroff spectral factorization&lt;br /&gt;
* [http://reproducibility.org/RSF/sflaps.html laps]: Compute lagged-products &lt;br /&gt;
* [http://reproducibility.org/RSF/sflinefit.html linefit]: Fit a line to a set of points in 2-D&lt;br /&gt;
* [http://reproducibility.org/RSF/sflopef.html lopef]: Local Prediction-Error Filter (1-D, 2-D, and 3-D)&lt;br /&gt;
* [http://reproducibility.org/RSF/sflpef.html lpef]: Find PEF on aliased traces&lt;br /&gt;
* [http://reproducibility.org/RSF/sflpf.html lpf]: Local prefiction filter (n-dimensional)&lt;br /&gt;
* [http://reproducibility.org/RSF/sflstk.html lstk]: Local slant stacks (2D) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfmspef.html mspef]: Multi-scale PEF estimation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfnhelicon.html nhelicon]: Non-stationary helix convolution and deconvolution&lt;br /&gt;
* [http://reproducibility.org/RSF/sfnpef.html npef]: Estimate Non-stationary PEF in N dimensions&lt;br /&gt;
* [http://reproducibility.org/RSF/sfocparcel.html ocparcel]: Patching test for out-of-core patching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfoctentwt.html octentwt]: Tent-like weight for out-of-core patching&lt;br /&gt;
* [http://reproducibility.org/RSF/sfoff2abs3.html off2abs3]: Transform vector-offset to absolute-offset &lt;br /&gt;
* [http://reproducibility.org/RSF/sfoff2abs.html off2abs]: Transform vector-offset to absolute-offset &lt;br /&gt;
* [http://reproducibility.org/RSF/sfofpwd2.html ofpwd2]: Objective function of two dips estimation with PWD filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfofpwd.html ofpwd]: Objective function of dip estimation with PWD filters&lt;br /&gt;
* [http://reproducibility.org/RSF/sfofsemb.html ofsemb]: Objective function of dip estimation with semblance&lt;br /&gt;
* [http://reproducibility.org/RSF/sfparcel.html parcel]: Patching test&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpatch.html patch]: Patching (N-dimensional)&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpef.html pef]: Multi-dimensional PEF (prediction error filter) estimation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpostfilter2.html postfilter2]: Convert B-spline coefficients to data in 2-D&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpredict.html predict]: 2-D plane-wave prediction&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpwd.html pwd]: 3-D plane wave destruction&lt;br /&gt;
* [http://reproducibility.org/RSF/sfpwdsigk.html pwdsigk]: Signal component separation using plane-wave destruction&lt;br /&gt;
* [http://reproducibility.org/RSF/sfrefer.html refer]: Subtract a reference from a grid&lt;br /&gt;
* [http://reproducibility.org/RSF/sfreg2tri.html reg2tri]: Decimate a regular grid to triplets for triangulation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfricker1.html ricker1]: Convolution with a Ricker wavelet&lt;br /&gt;
* [http://reproducibility.org/RSF/sfrweab.html rweab]: Riemannian Wavefield Extrapolation]:* a,b coefficients &lt;br /&gt;
* [http://reproducibility.org/RSF/sfrwemete2d.html rwemete2d]: 2-D metric tensor &lt;br /&gt;
* [http://reproducibility.org/RSF/sfseisigk.html seisigk]: Signal component separation using seislet transforms&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshapebin1.html shapebin1]: 1-D inverse interpolation with shaping regularization&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshapebin.html shapebin]: Data binning in 2-D slices by inverse interpolation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshapesigk.html shapesigk]: Signal component separation using plane-wave shaping&lt;br /&gt;
* [http://reproducibility.org/RSF/sfshotprop.html shotprop]: Shot propagation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfsic3d.html sic3d]: Local slant stacks IC&lt;br /&gt;
* [http://reproducibility.org/RSF/sfsic.html sic]: Local slant stacks IC&lt;br /&gt;
* [http://reproducibility.org/RSF/sfsplinebank.html splinebank]: Prepare a filter bank for B-spline plane wave filters &lt;br /&gt;
* [http://reproducibility.org/RSF/sfsplinefilter.html splinefilter]: Convert data to B-spline coefficients &lt;br /&gt;
* [http://reproducibility.org/RSF/sfsrsyn.html srsyn]: Synthesize shot/receiver wavefields for 3-D SR migration &lt;br /&gt;
* [http://reproducibility.org/RSF/sftan2ang.html tan2ang]: Compute cos(theta) from 1/|pm| for time-shift imaging condition &lt;br /&gt;
* [http://reproducibility.org/RSF/sftcor.html tcor]: Interferometric cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sftentwt.html tentwt]: Tent-like weight for patching&lt;br /&gt;
* [http://reproducibility.org/RSF/sftimeshift.html timeshift]: Apply variable time shifts using plane-wave construction&lt;br /&gt;
* [http://reproducibility.org/RSF/sftrapez.html trapez]: Convolution with a trapezoidal filter&lt;br /&gt;
* [http://reproducibility.org/RSF/sftree.html tree]: Multiple arrivals with a fast algorithm&lt;br /&gt;
* [http://reproducibility.org/RSF/sftri2reg.html tri2reg]: Interpolate triangulated triplets to a regular grid&lt;br /&gt;
* [http://reproducibility.org/RSF/sftrirand.html trirand]: Edit points for triangulation by removing similar and randomizing&lt;br /&gt;
* [http://reproducibility.org/RSF/sftspline.html tspline]: Helix filters for spline in tension &lt;br /&gt;
* [http://reproducibility.org/RSF/sftwofreq2.html twofreq2]: 2-D two spectral component estimation&lt;br /&gt;
* [http://reproducibility.org/RSF/sfucor.html ucor]: Interferometric cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfwarp1.html warp1]: Multicomponent data registration by 1-D warping&lt;br /&gt;
* [http://reproducibility.org/RSF/sfwarpadd.html warpadd]: Add a perturbation to the warping function&lt;br /&gt;
* [http://reproducibility.org/RSF/sfwarpscan.html warpscan]: Multicomponent data registration analysis&lt;br /&gt;
* [http://reproducibility.org/RSF/sfwdf.html wdf]: Assymptotic Wigner distribution &lt;br /&gt;
* [http://reproducibility.org/RSF/sfwigner.html wigner]: Assymptotic Wigner distribution in space-time &lt;br /&gt;
* [http://reproducibility.org/RSF/sfwilson.html wilson]: Wilson-Burg spectral factorization&lt;br /&gt;
* [http://reproducibility.org/RSF/sfxcor.html xcor]: Cross-correlation of time series (zero-lag output) &lt;br /&gt;
* [http://reproducibility.org/RSF/sfztrace.html ztrace]: Multiple arrivals by depth marching&lt;br /&gt;
* The SCons macros in &amp;lt;tt&amp;gt;RSFSRC/book/packages&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1975</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1975"/>
		<updated>2011-08-06T16:22:39Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Fedora, CentOS, Scientific Linux, openSUSE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Compilers==&lt;br /&gt;
Madagascar has been built successfully with the following compilers, and possibly with others:&lt;br /&gt;
* gcc&lt;br /&gt;
* Intel (icc/ifort)&lt;br /&gt;
* open64&lt;br /&gt;
* clang&lt;br /&gt;
&lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS, Scientific Linux, openSUSE==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
Names of packages that are runtime dependencies are &#039;&#039;&#039;highlighted&#039;&#039;&#039; in the tables below (task under construction).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==OpenSolaris==&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;pkg&amp;lt;/tt&amp;gt; to install missing components such as X11 headers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
pfexec pkg install SUNWxorg-headers&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=1974</id>
		<title>Guide to madagascar programs</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_programs&amp;diff=1974"/>
		<updated>2011-08-06T02:51:01Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Seismic programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/prog.tex?view=markup book/rsf/rsf/prog.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide introduces some of the most used &amp;lt;tt&amp;gt;madagascar&amp;lt;/tt&amp;gt; programs and illustrates their usage with examples.&lt;br /&gt;
=Main programs=&lt;br /&gt;
The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/ system/main] in the Madagascar distribution. The &amp;quot;main&amp;quot; programs perform general-purpose operations on RSF hypercubes regardless of the data dimensionality or physical dimensions.&lt;br /&gt;
&lt;br /&gt;
==sfadd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add, multiply, or divide  RSF datasets.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfadd &amp;gt; out.rsf scale= add= sqrt= abs= log= exp= mode= [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | The various operations, if selected, occur in the following order:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;(1) Take absolute value, abs=&amp;lt;br&amp;gt;(2) Add a scalar, add=&amp;lt;br&amp;gt;(3) Take the natural logarithm, log=&amp;lt;br&amp;gt;(4) Take the square root, sqrt=&amp;lt;br&amp;gt;(5) Multiply by a scalar, scale=&amp;lt;br&amp;gt;(6) Compute the base-e exponential, exp=&amp;lt;br&amp;gt;(7) Add, multiply, or divide the data sets, mode=&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfadd operates on integer, float, or complex data, but all the input&amp;lt;br&amp;gt;and output files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfadd is sfmath, which is more versatile, but may be&amp;lt;br&amp;gt;less efficient.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;abs=&#039;&#039;&#039; ||   || 	If true take absolute value  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;add=&#039;&#039;&#039; ||   || 	Scalar values to add to each dataset  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;exp=&#039;&#039;&#039; ||   || 	If true compute exponential  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;log=&#039;&#039;&#039; ||   || 	If true take logarithm  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mode=&#039;&#039;&#039; ||   || 	&#039;a&#039; means add (default), &amp;lt;br&amp;gt;       &#039;p&#039; or &#039;m&#039; means multiply, &amp;lt;br&amp;gt;       &#039;d&#039; means divide&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;scale=&#039;&#039;&#039; ||   || 	Scalar values to multiply each dataset with  [nin]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bools  &#039;&#039; || &#039;&#039;&#039;sqrt=&#039;&#039;&#039; ||   || 	If true take square root  [nin]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfadd&amp;lt;/tt&amp;gt; is useful for combining (adding, dividing, or&lt;br /&gt;
multiplying) several datasets. What if you want to subtract two&lt;br /&gt;
datasets? Easy. Use the &amp;lt;tt&amp;gt;scale&amp;lt;/tt&amp;gt; parameter as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfadd &amp;lt; data1.rsf data2.rsf scale=1,-1 &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The same task can be accomplished with the more general &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; program:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath one=data1.rsf two=data2.rsf output=&#039;one-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath &amp;lt; data1.rsf two=data2.rsf output=&#039;input-two&#039; &amp;gt; diff.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In both cases, the size and shape of &amp;lt;tt&amp;gt;data1.rsf&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;data2.rsf&amp;lt;/tt&amp;gt; hypercubes should be the same, and a warning&lt;br /&gt;
message is printed out if the the axis sampling parameters (such as&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;) in these files are different.&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/add.c?view=markup system/main/add.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* find number of input files */&lt;br /&gt;
    if (isatty(fileno(stdin))) { &lt;br /&gt;
        /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Collect input files in the &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; array from all command-line&lt;br /&gt;
parameters that don&#039;t contain an &amp;quot;&amp;lt;tt&amp;gt;=&amp;lt;/tt&amp;gt;&amp;quot; sign. The total number&lt;br /&gt;
of input files in &amp;lt;tt&amp;gt;nin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) continue; &lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
    /* nin = no of input files*/&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A helper function &amp;lt;tt&amp;gt;check_compat&amp;lt;/tt&amp;gt; checks the compatibility of&lt;br /&gt;
input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void &lt;br /&gt;
check_compat (sf_datatype type /* data type */, &lt;br /&gt;
	      size_t      nin  /* number of files */, &lt;br /&gt;
	      sf_file*    in   /* input files [nin] */, &lt;br /&gt;
	      int         dim  /* file dimensionality */, &lt;br /&gt;
	      const int*  n    /* dimensions [dim] */)&lt;br /&gt;
/* Check that the input files are compatible. &lt;br /&gt;
   Issue error for type mismatch or size mismatch.&lt;br /&gt;
   Issue warning for grid parameters mismatch. */&lt;br /&gt;
{&lt;br /&gt;
    int ni, id;&lt;br /&gt;
    size_t i;&lt;br /&gt;
    float d, di, o, oi;&lt;br /&gt;
    char key[3];&lt;br /&gt;
    const float tol=1.e-5; /* tolerance for comparison */&lt;br /&gt;
    &lt;br /&gt;
    for (i=1; i &amp;lt; nin; i++) {&lt;br /&gt;
	if (sf_gettype(in[i]) != type) &lt;br /&gt;
	    sf_error (&amp;quot;type mismatch: need %d&amp;quot;,type);&lt;br /&gt;
	for (id=1; id &amp;lt;= dim; id++) {&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,id);&lt;br /&gt;
	    if (!sf_histint(in[i],key,&amp;amp;ni) || ni != n[id-1])&lt;br /&gt;
		sf_error(&amp;quot;%s mismatch: need %d&amp;quot;,key,n[id-1]);&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;d%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;d)) {&lt;br /&gt;
		if (!sf_histfloat(in[i],key,&amp;amp;di) || &lt;br /&gt;
		    (fabsf(di-d) &amp;gt; tol*fabsf(d)))&lt;br /&gt;
		    sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,d);&lt;br /&gt;
	    } else {&lt;br /&gt;
		d = 1.;&lt;br /&gt;
	    }&lt;br /&gt;
	    (void) snprintf(key,3,&amp;quot;o%d&amp;quot;,id);&lt;br /&gt;
	    if (sf_histfloat(in[0],key,&amp;amp;o) &amp;amp;&amp;amp; &lt;br /&gt;
		(!sf_histfloat(in[i],key,&amp;amp;oi) || &lt;br /&gt;
		 (fabsf(oi-o) &amp;gt; tol*fabsf(d))))&lt;br /&gt;
		sf_warning(&amp;quot;%s mismatch: need %g&amp;quot;,key,o);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we enter the main loop, where input data are getting read&lt;br /&gt;
buffer by buffer and combined in the total product depending on the&lt;br /&gt;
data type.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nbuf /= sf_esize(in[0]); nsiz &amp;gt; 0; nsiz -= nbuf) {&lt;br /&gt;
	if (nbuf &amp;gt; nsiz) nbuf=nsiz;&lt;br /&gt;
&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    collect = (bool) (j != 0);&lt;br /&gt;
	    switch(type) {&lt;br /&gt;
		case SF_FLOAT:&lt;br /&gt;
		    sf_floatread((float*) bufi,&lt;br /&gt;
				 nbuf,&lt;br /&gt;
				 in[j]);	    &lt;br /&gt;
		    add_float(collect, &lt;br /&gt;
			      nbuf,&lt;br /&gt;
			      (float*) buf,&lt;br /&gt;
			      (const float*) bufi, &lt;br /&gt;
			      cmode, &lt;br /&gt;
			      scale[j], &lt;br /&gt;
			      add[j], &lt;br /&gt;
			      abs_flag[j], &lt;br /&gt;
			      log_flag[j], &lt;br /&gt;
			      sqrt_flag[j], &lt;br /&gt;
			      exp_flag[j]);&lt;br /&gt;
		    break;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data combination program for floating point numbers is&lt;br /&gt;
&amp;lt;tt&amp;gt;add_float&amp;lt;/tt&amp;gt;.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
static void add_float (bool   collect,    /* if collect */&lt;br /&gt;
		       size_t nbuf,       /* buffer size */&lt;br /&gt;
		       float* buf,        /* output [nbuf] */&lt;br /&gt;
		       const float* bufi, /* input  [nbuf] */  &lt;br /&gt;
		       char   cmode,      /* operation */&lt;br /&gt;
		       float  scale,      /* scale factor */&lt;br /&gt;
		       float  add,        /* add factor */&lt;br /&gt;
		       bool   abs_flag,   /* if abs */&lt;br /&gt;
		       bool   log_flag,   /* if log */&lt;br /&gt;
		       bool   sqrt_flag,  /* if sqrt */&lt;br /&gt;
		       bool   exp_flag    /* if exp */)&lt;br /&gt;
/* Add floating point numbers */&lt;br /&gt;
{&lt;br /&gt;
    size_t j;&lt;br /&gt;
    float f;&lt;br /&gt;
&lt;br /&gt;
    for (j=0; j &amp;lt; nbuf; j++) {&lt;br /&gt;
	f = bufi[j];&lt;br /&gt;
	if (abs_flag)    f = fabsf(f);&lt;br /&gt;
	f += add;&lt;br /&gt;
	if (log_flag)    f = logf(f);&lt;br /&gt;
	if (sqrt_flag)   f = sqrtf(f);&lt;br /&gt;
	if (1. != scale) f *= scale;&lt;br /&gt;
	if (exp_flag)    f = expf(f);&lt;br /&gt;
	if (collect) {&lt;br /&gt;
	    switch (cmode) {&lt;br /&gt;
		case &#039;p&#039;: /* product */&lt;br /&gt;
		case &#039;m&#039;: /* multiply */&lt;br /&gt;
		    buf[j] *= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		case &#039;d&#039;: /* delete */&lt;br /&gt;
		    if (f != 0.) buf[j] /= f;&lt;br /&gt;
		    break;&lt;br /&gt;
		default:  /* add */&lt;br /&gt;
		    buf[j] += f;&lt;br /&gt;
		    break;&lt;br /&gt;
	    }&lt;br /&gt;
	} else {&lt;br /&gt;
	    buf[j] = f;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display dataset attributes.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfattr &amp;lt; in.rsf want=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    &amp;lt;br&amp;gt;Sample output from &amp;quot;sfspike n1=100 | sfbandpass fhi=60 | sfattr&amp;quot;&amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;rms = 0.992354 &amp;lt;br&amp;gt;mean value = 0.987576 &amp;lt;br&amp;gt;2-norm value = 9.92354 &amp;lt;br&amp;gt;variance = 0.00955481 &amp;lt;br&amp;gt;standard deviation = 0.0977487 &amp;lt;br&amp;gt;maximum value = 1.12735 at 97 &amp;lt;br&amp;gt;minimum value = 0.151392 at 100 &amp;lt;br&amp;gt;number of nonzero samples = 100 &amp;lt;br&amp;gt;total number of samples = 100 &amp;lt;br&amp;gt;******************************************* &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;rms                = sqrt[ sum(data^2) / n ]&amp;lt;br&amp;gt;mean               = sum(data) / n&amp;lt;br&amp;gt;norm               = sum(abs(data)^lval)^(1/lval)&amp;lt;br&amp;gt;variance           = [ sum(data^2) - n*mean^2 ] / [ n-1 ]&amp;lt;br&amp;gt;standard deviation = sqrt [ variance ]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int &#039;&#039; || &#039;&#039;&#039;lval=2&#039;&#039;&#039; ||   || 	norm option, lval is a non-negative integer, computes the vector lval-norm&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;want=&#039;&#039;&#039; ||   || 	&#039;all&#039;(default),&#039;rms&#039;,&#039;mean&#039;,&#039;norm&#039;,&#039;var&#039;,&#039;std&#039;,&#039;max&#039;,&#039;min&#039;,&#039;nonzero&#039;,&#039;samples&#039;,&#039;short&#039; &lt;br /&gt;
:want=   &#039;rms&#039; displays the root mean square&lt;br /&gt;
:want=   &#039;norm&#039; displays the square norm, otherwise specified by lval.&lt;br /&gt;
:want=   &#039;var&#039; displays the variance&lt;br /&gt;
:want=   &#039;std&#039; displays the standard deviation&lt;br /&gt;
:want=   &#039;nonzero&#039; displays number of nonzero samples&lt;br /&gt;
:want=   &#039;samples&#039; displays total number of samples&lt;br /&gt;
:want=   &#039;short&#039; displays a short one-line version&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt; is a useful diagnostic program. It reports certain&lt;br /&gt;
statistical values for an RSF dataset: RMS (root-mean-square)&lt;br /&gt;
amplitude, mean value, vector norm value, variance, standard deviation,&lt;br /&gt;
maximum and minimum values, number of nonzero samples, and the total&lt;br /&gt;
number of samples.&lt;br /&gt;
If we denote data values as &amp;lt;math&amp;gt;d_i&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;i=0,1,2,\ldots,n&amp;lt;/math&amp;gt;, then the RMS&lt;br /&gt;
value is &amp;lt;math&amp;gt;\sqrt{\frac{1}{n}\,\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the mean&lt;br /&gt;
value is &amp;lt;math&amp;gt;\frac{1}{n}\,\sum\limits_{i=0}^n d_i&amp;lt;/math&amp;gt;, the &amp;lt;math&amp;gt;L_2&amp;lt;/math&amp;gt;-norm value&lt;br /&gt;
is &amp;lt;math&amp;gt;\sqrt{\sum\limits_{i=0}^n d_i^2}&amp;lt;/math&amp;gt;, the variance is&lt;br /&gt;
&amp;lt;math&amp;gt;\frac{1}{n-1}\,\left[\sum\limits_{i=0}^n d_i^2 - \frac{1}{n}\left(\sum\limits_{i=0}^n d_i\right)^2\right]&amp;lt;/math&amp;gt;, and the standard&lt;br /&gt;
deviation is the square root of the variance. Using &amp;lt;tt&amp;gt;sfattr&amp;lt;/tt&amp;gt;&lt;br /&gt;
is a quick way to see the distribution of data values and check it for anomalies.&lt;br /&gt;
&lt;br /&gt;
The output can be parsed using utilities such as &amp;lt;tt&amp;gt;awk&amp;lt;/tt&amp;gt;, to extract only a numeric value for feeding it as a parameter value into a command line interface. Notice the backticks in the example below:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfgrey &amp;lt;vel.rsf allpos=y bias=`sfattr &amp;lt;vel.rsf want=min | awk &#039;{print $4}&#039;` | sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/attr.c?view=markup system/main/attr.c]====&lt;br /&gt;
&lt;br /&gt;
Computations start by finding the input data (&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;) size&lt;br /&gt;
(&amp;lt;tt&amp;gt;nsiz&amp;lt;/tt&amp;gt;) and dimensions (&amp;lt;tt&amp;gt;dim&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    dim = (size_t) sf_filedims (in,n);&lt;br /&gt;
    for (nsiz=1, i=0; i &amp;lt; dim; i++) {&lt;br /&gt;
	nsiz *= n[i];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the main loop, we read the input data buffer by buffer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft=nsiz; nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (bufsiz &amp;lt; nleft)? bufsiz: nleft;&lt;br /&gt;
	switch (type) {&lt;br /&gt;
	    case SF_FLOAT: &lt;br /&gt;
		sf_floatread((float*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_INT:&lt;br /&gt;
		sf_intread((int*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_COMPLEX:&lt;br /&gt;
		sf_complexread((sf_complex*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_UCHAR:&lt;br /&gt;
		sf_ucharread((unsigned char*) buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	    case SF_CHAR:&lt;br /&gt;
	    default:&lt;br /&gt;
		sf_charread(buf,nbuf,in);&lt;br /&gt;
		break;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data attributes are accumulated in corresponding double-precision&lt;br /&gt;
variables. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	    fsum += f;&lt;br /&gt;
	    fsqr += f*f;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, the attributes are reduced and printed out.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    fmean = fsum/nsiz;&lt;br /&gt;
    if (lval==2)      fnorm = sqrt(fsqr);&lt;br /&gt;
    else if (lval==0) fnorm = nsiz-nzero;&lt;br /&gt;
    else              fnorm = pow(flval,1./lval);&lt;br /&gt;
    frms = sqrt(fsqr/nsiz);&lt;br /&gt;
    if (nsiz &amp;gt; 1) fvar = (fsqr-nsiz*fmean*fmean)/(nsiz-1);&lt;br /&gt;
    else          fvar = 0.0;&lt;br /&gt;
    fstd = sqrt(fvar);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;rms&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;rms = %g \n&amp;quot;,(float) frms);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;mean&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;mean value = %g \n&amp;quot;,(float) fmean);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;norm&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;%d-norm value = %g \n&amp;quot;,lval,(float) fnorm);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;var&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;variance = %g \n&amp;quot;,(float) fvar);&lt;br /&gt;
    if(NULL==want || 0==strcmp(want,&amp;quot;std&amp;quot;))&lt;br /&gt;
	printf(&amp;quot;standard deviation = %g \n&amp;quot;,(float) fstd);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcat==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Concatenate datasets. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcat &amp;gt; out.rsf space= axis=3 nspace=(int) (ni/(20*nin) + 1) [&amp;lt;file0.rsf] file1.rsf file2.rsf ... &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfmerge inserts additional space between merged data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis being merged&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nspace=(int) (ni/(20*nin) + 1)&#039;&#039;&#039; ||   || 	if space=y, number of traces to insert&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;space=&#039;&#039;&#039; ||  [y/n] || 	Insert additional space.&lt;br /&gt;
:y is default for sfmerge, n is default for sfcat&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; concatenate two or more files&lt;br /&gt;
together along a particular axis. It is the same program, only&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; has the default &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;&lt;br /&gt;
has the default &amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcat one.rsf one.rsf axis=1 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=4           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        12 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmerge one.rsf one.rsf axis=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=7           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        14 elements 56 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, an extra empty trace is inserted between the two merged files.&lt;br /&gt;
The axes that are not being merged are checked for consistency:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfcat one.rsf two.rsf &amp;gt; three.rsf&lt;br /&gt;
sfcat: n2 mismatch: need 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cat.c?view=markup system/main/cat.c]====&lt;br /&gt;
The first input file is either in the list or in the standard input.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    in = (sf_file*) sf_alloc ((size_t) argc,sizeof(sf_file));&lt;br /&gt;
&lt;br /&gt;
    if (!sf_stdin()) { /* no input file in stdin */&lt;br /&gt;
	nin=0;&lt;br /&gt;
    } else {&lt;br /&gt;
	in[0] = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
	nin=1;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Everything on the command line that does not contain a &amp;quot;=&amp;quot; sign is&lt;br /&gt;
treated as a file name, and the corresponding file object is added to the list.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { /* collect inputs */&lt;br /&gt;
	if (NULL != strchr(argv[i],&#039;=&#039;)) &lt;br /&gt;
	    continue; /* not a file */&lt;br /&gt;
	in[nin] = sf_input(argv[i]);&lt;br /&gt;
	nin++;&lt;br /&gt;
    }&lt;br /&gt;
    if (0==nin) sf_error (&amp;quot;no input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As explained above, if the &amp;lt;tt&amp;gt;space=&amp;lt;/tt&amp;gt; parameter is not set, it is&lt;br /&gt;
inferred from the program name: &amp;lt;tt&amp;gt;sfmerge&amp;lt;/tt&amp;gt; corresponds to&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; corresponds to &amp;lt;tt&amp;gt;space=n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    if (!sf_getbool(&amp;quot;space&amp;quot;,&amp;amp;space)) {&lt;br /&gt;
	/* Insert additional space.&lt;br /&gt;
	   y is default for sfmerge, n is default for sfcat */&lt;br /&gt;
	prog = sf_getprog();&lt;br /&gt;
	if (NULL != strstr (prog, &amp;quot;merge&amp;quot;)) {&lt;br /&gt;
	    space = true;&lt;br /&gt;
	} else if (NULL != strstr (prog, &amp;quot;cat&amp;quot;)) {&lt;br /&gt;
	    space = false;&lt;br /&gt;
	} else {&lt;br /&gt;
	    sf_warning(&amp;quot;%s is neither merge nor cat,&amp;quot;&lt;br /&gt;
		       &amp;quot; assume merge&amp;quot;,prog);&lt;br /&gt;
	    space = true;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find the axis for the merging (from the command line &amp;lt;tt&amp;gt;axis=&amp;lt;/tt&amp;gt;&lt;br /&gt;
argument) and figure out two sizes: &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; for everything after&lt;br /&gt;
the axis and &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; for everything before the axis.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    n1=1;&lt;br /&gt;
    n2=1;&lt;br /&gt;
    for (i=1; i &amp;lt;= dim; i++) {&lt;br /&gt;
	if      (i &amp;lt; axis) n1 *= n[i-1];&lt;br /&gt;
	else if (i &amp;gt; axis) n2 *= n[i-1];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the output, the selected axis will get extended.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* figure out the length of extended axis */&lt;br /&gt;
    ni = 0;&lt;br /&gt;
    for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	ni += naxis[j];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (space) {&lt;br /&gt;
	if (!sf_getint(&amp;quot;nspace&amp;quot;,&amp;amp;nspace)) &lt;br /&gt;
	    nspace = (int) (ni/(20*nin) + 1);&lt;br /&gt;
	/* if space=y, number of traces to insert */ &lt;br /&gt;
	ni += nspace*(nin-1);&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
    (void) snprintf(key,3,&amp;quot;n%d&amp;quot;,axis);&lt;br /&gt;
    sf_putint(out,key,(int) ni);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest is simple: loop through the datasets reading and writing the&lt;br /&gt;
data in buffer-size chunks and adding extra empty chunks if&lt;br /&gt;
&amp;lt;tt&amp;gt;space=y&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
	for (j=0; j &amp;lt; nin; j++) {&lt;br /&gt;
	    for (ni = n1*naxis[j]*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charread (buf,nbuf,in[j]);&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	    if (!space || j == nin-1) continue;&lt;br /&gt;
	    /* Add spaces */&lt;br /&gt;
	    memset(buf,0,BUFSIZ);&lt;br /&gt;
	    for (ni = n1*nspace*esize; ni &amp;gt; 0; ni -= nbuf) {&lt;br /&gt;
		nbuf = (BUFSIZ &amp;lt; ni)? BUFSIZ: ni;&lt;br /&gt;
		sf_charwrite (buf,nbuf,out);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for complex linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;dat=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;mod=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A simple demonstration of the program can be made taking advantage that the complex-to-complex FFT is a linear operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike n1=100 | sfrtoc &amp;gt; spike.rsf&lt;br /&gt;
&amp;lt; spike.rsf sffft axis=1 pad=1 &amp;gt; spike2.rsf&lt;br /&gt;
sfcdottest sffft mod=spike.rsf dat=spike2.rsf axis=1 pad=1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output should show values identical down to the last decimal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfcdottest:  L[m]*d=(3.73955,-1.86955)&lt;br /&gt;
sfcdottest: L&#039;[d]*m=(3.73955,-1.86955)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcmplx==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a complex dataset from its real and imaginary parts.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcmplx &amp;gt; cmplx.rsf real.rsf imag.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | There has to be only two input files specified and no additional parameters.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt; simply creates a complex dataset from its real and&lt;br /&gt;
imaginary parts. The reverse operation can be accomplished with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Example of &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcmplx one.rsf one.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ sfin cmplx.rsf&lt;br /&gt;
cmplx.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/cmplx.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 48 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cmplx.c?view=markup system/main/cmplx.c]====&lt;br /&gt;
The program flow is simple. First, get the names of the input files.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are real and imaginary files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == real) {&lt;br /&gt;
		real = sf_input (argv[i]);&lt;br /&gt;
	    } else {&lt;br /&gt;
		imag = sf_input (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == imag) {&lt;br /&gt;
	if (NULL == real) sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
	/* if only one input, real is in stdin */&lt;br /&gt;
	imag = real;&lt;br /&gt;
	real = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main part of the program reads the real and imaginary parts buffer by buffer and assembles and writes out the complex input. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (nleft= (size_t) (rsize*resize); nleft &amp;gt; 0; nleft -= nbuf) {&lt;br /&gt;
	nbuf = (BUFSIZ &amp;lt; nleft)? BUFSIZ: nleft;&lt;br /&gt;
	sf_charread(rbuf,nbuf,real);&lt;br /&gt;
	sf_charread(ibuf,nbuf,imag);&lt;br /&gt;
	for (i=0; i &amp;lt; nbuf; i += resize) {&lt;br /&gt;
	    memcpy(cbuf+2*i,       rbuf+i,(size_t) resize);&lt;br /&gt;
	    memcpy(cbuf+2*i+resize,ibuf+i,(size_t) resize);&lt;br /&gt;
	}&lt;br /&gt;
	sf_charwrite(cbuf,2*nbuf,cmplx);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
==sfconjgrad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic conjugate-gradient solver for linear inversion &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfconjgrad &amp;lt; dat.rsf mod=mod.rsf &amp;gt; to.rsf &amp;lt; from.rsf &amp;gt; out.rsf niter=1&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=1&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is a generic program for least-squares linear&lt;br /&gt;
inversion with the [http://en.wikipedia.org/wiki/Conjugate_gradient_method conjugate-gradient method]. Suppose you have an&lt;br /&gt;
executable program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the&lt;br /&gt;
standard input and produces an RSF file in the standard output. It may&lt;br /&gt;
take any number of additional parameters but one of them must be&lt;br /&gt;
&amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint&lt;br /&gt;
(&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.  The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically&lt;br /&gt;
an RSF program but it could be anything (a script, a multiprocessor&lt;br /&gt;
MPI program, etc.) as long as it implements a linear operator&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint. There are no restrictions on the data&lt;br /&gt;
size or shape. You can easily test the adjointness with&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; program searches for a&lt;br /&gt;
vector &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; that minimizes the least-square misfit &lt;br /&gt;
&amp;lt;math&amp;gt;\|\mathbf{d - L\,m}\|^2&amp;lt;/math&amp;gt; for the given input data vector &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The pseudocode for &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt; is given at the end of the [http://www.reproducibility.org/RSF/book/gee/lsq/paper.pdf &amp;quot;Model fitting with least squares&amp;quot; chapter] of &#039;&#039;Imaging Estimation by Example&#039;&#039; by Jon Claerbout, with the earliest form published in [http://sepwww.stanford.edu/data/media/public/oldreports/sep48/48_25.pdf &amp;quot;Conjugate Gradient Tutorial&amp;quot;] (SEP-48, 1986, same author). A simple toy implementation with a small matrix shows that this is algorithm produces the same steps as the algorithm described in equations 45-49 of [http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf &amp;quot;An introduction to the Conjugate Gradient Method Without the Agonizing Pain&amp;quot;] by J.R. Shewchuk, 1994, when the equation &amp;lt;math&amp;gt;A^T A x = A^T b&amp;lt;/math&amp;gt; (in Shewchuk&#039;s notation) is solved. Multiplying with the transpose ensures a correct solution even when matrix A is square but not symmetric, or not square at all. The program [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad] implements this algorithm for the case when inputs are complex.&lt;br /&gt;
&lt;br /&gt;
Here is an example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test to&lt;br /&gt;
check that the adjoint mode works correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=5.28394&lt;br /&gt;
sfdottest: L&#039;[d]*m=5.28394&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your numbers may be different because &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; generates new&lt;br /&gt;
random input on each run.&lt;br /&gt;
Next, let us make some random data with &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfnoise seed=2005 rep=y &amp;lt; vec.rsf &amp;gt; dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and try to invert the filtering operation using &amp;lt;tt&amp;gt;sfconjgrad&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfconjgrad sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
mod=vec.rsf &amp;lt; dat.rsf &amp;gt; mod.rsf niter=10&lt;br /&gt;
sfconjgrad: iter 1 of 10&lt;br /&gt;
sfconjgrad: grad=3253.65&lt;br /&gt;
sfconjgrad: iter 2 of 10&lt;br /&gt;
sfconjgrad: grad=289.421&lt;br /&gt;
sfconjgrad: iter 3 of 10&lt;br /&gt;
sfconjgrad: grad=92.3481&lt;br /&gt;
sfconjgrad: iter 4 of 10&lt;br /&gt;
sfconjgrad: grad=36.9417&lt;br /&gt;
sfconjgrad: iter 5 of 10&lt;br /&gt;
sfconjgrad: grad=18.7228&lt;br /&gt;
sfconjgrad: iter 6 of 10&lt;br /&gt;
sfconjgrad: grad=11.1794&lt;br /&gt;
sfconjgrad: iter 7 of 10&lt;br /&gt;
sfconjgrad: grad=7.26941&lt;br /&gt;
sfconjgrad: iter 8 of 10&lt;br /&gt;
sfconjgrad: grad=5.15945&lt;br /&gt;
sfconjgrad: iter 9 of 10&lt;br /&gt;
sfconjgrad: grad=4.23055&lt;br /&gt;
sfconjgrad: iter 10 of 10&lt;br /&gt;
sfconjgrad: grad=3.57495&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output shows that, in 10 iterations, the norm of the gradient vector decreases by almost 1000. &lt;br /&gt;
We can check the residual misfit before&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; dat.rsf sfattr want=norm&lt;br /&gt;
norm value = 49.7801&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and after&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfhelicon filt=flt.rsf lag=lag.rsf &amp;lt; mod.rsf | \&lt;br /&gt;
sfadd scale=1,-1 dat.rsf | sfattr want=norm&lt;br /&gt;
norm value = 5.73563&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In 10 iterations, the misfit decreased by an order of magnitude. The&lt;br /&gt;
result can be improved by running the program for more iterations.&lt;br /&gt;
&lt;br /&gt;
An equivalent implementation for complex-valued inputs is [http://www.reproducibility.org/RSF/sfcconjgrad.html sfcconjgrad]. A simple, lightweight Python implementation can be found in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/user/fomels/conjgrad.py?view=markup $RSFROOT/lib/conjgrad.py].&lt;br /&gt;
&lt;br /&gt;
==sfcp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Copy or move a dataset.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcp in.rsf out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | sfcp - copy, sfmv - move.&amp;lt;br&amp;gt;Mimics standard Unix commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfmv&amp;lt;/tt&amp;gt; command imitate the Unix&lt;br /&gt;
&amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; commands and serve for copying and moving&lt;br /&gt;
RSF files. Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=2 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfin one.rsf&lt;br /&gt;
one.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/one.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
bash$ sfcp one.rsf two.rsf&lt;br /&gt;
bash$ sfin two.rsf&lt;br /&gt;
two.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/two.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=2           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        6 elements 24 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/cp.c?view=markup system/main/cp.c]====&lt;br /&gt;
First, we look for the two first command-line arguments that don&#039;t&lt;br /&gt;
have the &amp;quot;=&amp;quot; character in them and consider them as the names of the&lt;br /&gt;
input and the output files.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* the first two non-parameters are in and out files */&lt;br /&gt;
    for (i=1; i&amp;lt; argc; i++) { &lt;br /&gt;
	if (NULL == strchr(argv[i],&#039;=&#039;)) {&lt;br /&gt;
	    if (NULL == in) {&lt;br /&gt;
		infile = argv[i];&lt;br /&gt;
		in = sf_input (infile);&lt;br /&gt;
	    } else {&lt;br /&gt;
		out = sf_output (argv[i]);&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    if (NULL == in || NULL == out)&lt;br /&gt;
	sf_error (&amp;quot;not enough input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we use library functions &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_cp&amp;lt;/font&amp;gt; and &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;sf_rm&amp;lt;/font&amp;gt; to do the actual work.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_cp(in,out);&lt;br /&gt;
    if (NULL != strstr (sf_getprog(),&amp;quot;mv&amp;quot;)) &lt;br /&gt;
	sf_rm(infile,false,false,false);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfcut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcut &amp;lt; in.rsf &amp;gt; out.rsf verb=n [j1=1 j2=1 ... f1=0 f2=0 ... n1=n1 n2=n2 ... max1= max2= ... min1= min2= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | jN defines the jump in N-th dimension&amp;lt;br&amp;gt;fN is the window start&amp;lt;br&amp;gt;nN is the window size&amp;lt;br&amp;gt;minN and maxN is the maximum and minimum in N-th dimension&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Reverse of window. &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfcut&amp;lt;/tt&amp;gt; command is related to &amp;lt;tt&amp;gt;sfwindow&amp;lt;/tt&amp;gt; and has the same&lt;br /&gt;
set of arguments only instead of extracting the selected window, it fills it&lt;br /&gt;
with zeroes. The size of the input data is preserved. &lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; in.rsf&lt;br /&gt;
bash$ &amp;lt; in.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut n1=2 f1=1 n2=3 f2=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            0            0            1            1&lt;br /&gt;
  15:             1            0            0            1            1&lt;br /&gt;
  20:             1            0            0            1            1&lt;br /&gt;
bash$ &amp;lt; in.rsf sfcut j1=2 | sfdisfil&lt;br /&gt;
   0:             0            1            0            1            0&lt;br /&gt;
   5:             0            1            0            1            0&lt;br /&gt;
  10:             0            1            0            1            0&lt;br /&gt;
  15:             0            1            0            1            0&lt;br /&gt;
  20:             0            1            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfdd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert between different formats. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdd &amp;lt; in.rsf &amp;gt; out.rsf line=8 form= type= format=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;form=&#039;&#039;&#039; ||   || 	ascii, native, xdr&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Element format (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;line=8&#039;&#039;&#039; ||   || 	Number of numbers per line (for conversion to ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	int, float, complex&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; program is used to change either the form (&amp;lt;tt&amp;gt;ascii&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;native&amp;lt;/tt&amp;gt;) or the type (&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;char&amp;lt;/tt&amp;gt;) of the input dataset. &lt;br /&gt;
In the example below, we create a plain text (ASCII) file with numbers and&lt;br /&gt;
then use &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt; to generate an RSF file in &amp;lt;tt&amp;gt;xdr&amp;lt;/tt&amp;gt; form with&lt;br /&gt;
&amp;lt;tt&amp;gt;complex&amp;lt;/tt&amp;gt; numbers. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ cat test.txt&lt;br /&gt;
1 2 3 4 5 6&lt;br /&gt;
bash$ echo n1=6 data_format=ascii_int in=test.txt &amp;gt; test.rsf&lt;br /&gt;
bash$ sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;test.txt&amp;quot;&lt;br /&gt;
    esize=0 type=int form=ascii&lt;br /&gt;
    n1=6           d1=?           o1=?&lt;br /&gt;
        6 elements&lt;br /&gt;
bash$ sfdd &amp;lt; test.rsf form=xdr type=complex &amp;gt; test2.rsf&lt;br /&gt;
bash$ sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=xdr&lt;br /&gt;
    n1=3           d1=?           o1=?&lt;br /&gt;
        3 elements 24 bytes&lt;br /&gt;
bash$ sfdisfil &amp;lt; test2.rsf&lt;br /&gt;
   0:          1,         2i         3,         4i         5,         6i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To learn more about the RSF data format, consult the [[Guide to RSF file format| guide to RSF format]].&lt;br /&gt;
&lt;br /&gt;
==sfdisfil==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Print out data values.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdisfil &amp;lt; in.rsf number=y col=0 format= header= trailer=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Alternatively, use sfdd and convert to ASCII form.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;col=0&#039;&#039;&#039; ||   || 	Number of columns.&lt;br /&gt;
:The default depends on the data type:&lt;br /&gt;
:10 for int and char,&lt;br /&gt;
:5 for float,&lt;br /&gt;
:3 for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;format=&#039;&#039;&#039; ||   || 	Format for numbers (printf-style).&lt;br /&gt;
:The default depends on the data type:&amp;lt;br&amp;gt;       &amp;quot;%4d &amp;quot; for int and char,&amp;lt;br&amp;gt;       &amp;quot;%13.4g&amp;quot; for float,&amp;lt;br&amp;gt;       &amp;quot;%10.4g,%10.4gi&amp;quot; for complex&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;header=&#039;&#039;&#039; ||   || 	Optional header string to output before data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;number=y&#039;&#039;&#039; ||  [y/n] || 	If number the elements&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;trailer=&#039;&#039;&#039; ||   || 	Optional trailer string to output after data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; program simply dumps the data contents to the standard&lt;br /&gt;
output in a text form. It is used mostly for debugging purposes to quickly&lt;br /&gt;
examine RSF files. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath o1=0 d1=2 n1=12 output=x1 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
  10:            20           22&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output format is easily configurable.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil col=6 number=n format=&amp;quot;%5.1f&amp;quot;&lt;br /&gt;
  0.0  2.0  4.0  6.0  8.0 10.0&lt;br /&gt;
 12.0 14.0 16.0 18.0 20.0 22.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Along with &amp;lt;tt&amp;gt;sfdd&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt; provides a simple way to convert&lt;br /&gt;
RSF data to an ASCII form.&lt;br /&gt;
&lt;br /&gt;
==sfdottest==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generic dot-product test for linear operators with adjoints &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdottest mod=mod.rsf dat=dat.rsf &amp;gt; pip.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; is a generic dot-product test program for testing&lt;br /&gt;
linear operators. Suppose there is an executable program&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; that takes an RSF file from the standard input and&lt;br /&gt;
produces an RSF file in the standard output. It may take any number of&lt;br /&gt;
additional parameters but one of them must be &amp;lt;tt&amp;gt;adj=&amp;lt;/tt&amp;gt; that sets&lt;br /&gt;
the forward (&amp;lt;tt&amp;gt;adj=0&amp;lt;/tt&amp;gt;) or adjoint (&amp;lt;tt&amp;gt;adj=1&amp;lt;/tt&amp;gt;) operations.&lt;br /&gt;
The program &amp;lt;tt&amp;gt;&amp;lt;prog&amp;gt;&amp;lt;/tt&amp;gt; is typically an RSF program but it could&lt;br /&gt;
be anything (a script, a multiprocessor MPI program, etc.) as long as&lt;br /&gt;
it implements a linear operator &amp;lt;math&amp;gt;\mathbf{L}&amp;lt;/math&amp;gt; and its adjoint&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{L}^T&amp;lt;/math&amp;gt;. The &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program is testing the equality&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
d^T\,L\,m = m^T\,L^T\,d&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
by using random vectors &amp;lt;math&amp;gt;\mathbf{m}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{d}&amp;lt;/math&amp;gt;. You can invoke it with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest &amp;lt;prog&amp;gt; [optional aruments] mod=mod.rsf dat=dat.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;tt&amp;gt;mod.rsf&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;dat.rsf&amp;lt;/tt&amp;gt; are RSF files that&lt;br /&gt;
represent vectors from the model and data spaces. Pay attention to the &lt;br /&gt;
dimension and size of these vectors! If the program does not respond&lt;br /&gt;
for a very long time, it is quite possible that the dimension and size&lt;br /&gt;
of the vectors are inconsistent with the requirement of the program to be&lt;br /&gt;
tested. &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt;&lt;br /&gt;
does not create any temporary files and does not have any restrictive&lt;br /&gt;
limitations on the size of the vectors.&lt;br /&gt;
Here is an example. We first setup a vector with 100 elements using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; and then run &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; to test the&lt;br /&gt;
&amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; program. &amp;lt;tt&amp;gt;sfcausint&amp;lt;/tt&amp;gt; implements a linear&lt;br /&gt;
operator of causal integration and its adjoint, the anti-causal&lt;br /&gt;
integration.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 &amp;gt; vec.rsf&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1410.2&lt;br /&gt;
sfdottest: L&#039;[d]*m=1410.2&lt;br /&gt;
bash$ sfdottest sfcausint mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=1165.87&lt;br /&gt;
sfdottest: L&#039;[d]*m=1165.87&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The numbers are different on subsequent runs because of changing&lt;br /&gt;
seed in the random number generator.&lt;br /&gt;
Here is a somewhat more complicated example. The &amp;lt;tt&amp;gt;sfhelicon&amp;lt;/tt&amp;gt;&lt;br /&gt;
program implements Claerbout&#039;s multidimensional helical filtering&lt;br /&gt;
(Claerbout, 1998&amp;lt;ref&amp;gt;Claerbout, J.,  1998, Multidimensional recursive filters via a helix:  Geophysics, &#039;&#039;&#039;63&#039;&#039;&#039;, 1532--1541.&amp;lt;/ref&amp;gt;). It requires a filter to be specified in&lt;br /&gt;
addition to the input and output vectors. We create a helical &lt;br /&gt;
2-D filter using the Unix &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo 1 19 20 n1=3 n=20,20 data_format=ascii_int in=lag.rsf &amp;gt; lag.rsf&lt;br /&gt;
bash$ echo 1 1 1 a0=-3 n1=3 data_format=ascii_float in=flt.rsf &amp;gt; flt.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we create an example 2-D model and data vector with &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=50 n2=50 &amp;gt; vec.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now the &amp;lt;tt&amp;gt;sfdottest&amp;lt;/tt&amp;gt; program can perform the dot product test.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf&lt;br /&gt;
sfdottest:  L[m]*d=8.97375&lt;br /&gt;
sfdottest: L&#039;[d]*m=8.97375&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here is the same program tested in the inverse filtering mode:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfdottest sfhelicon filt=flt.rsf lag=lag.rsf \&lt;br /&gt;
&amp;gt; mod=vec.rsf dat=vec.rsf div=y&lt;br /&gt;
sfdottest:  L[m]*d=15.0222&lt;br /&gt;
sfdottest: L&#039;[d]*m=15.0222&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfget==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Output parameters from the header.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfget &amp;lt; in.rsf parform=y par1 par2 ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;parform=y&#039;&#039;&#039; ||  [y/n] || 	If y, print out parameter=value. If n, print out value.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt; program extracts a parameter value from an RSF file. It is&lt;br /&gt;
useful mostly for scripting. Here is, for example, a quick calculation of the&lt;br /&gt;
maximum value on the first axis in an RSF dataset (the output of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt;) using the standard Unix &amp;lt;tt&amp;gt;bc&amp;lt;/tt&amp;gt; calculator.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ ( sfspike n1=100 | sfget n1 d1 o1; echo &amp;quot;o1+(n1-1)*d1&amp;quot; ) | bc&lt;br /&gt;
.396&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See also &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Implementation: [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/main/get.c?view=markup system/main/get.c]====&lt;br /&gt;
The implementation is trivial. Loop through all command-line parameters that contain &lt;br /&gt;
the &amp;quot;=&amp;quot; character.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    for (i = 1; i &amp;lt; argc; i++) {&lt;br /&gt;
	key = argv[i];&lt;br /&gt;
	if (NULL != strchr(key,&#039;=&#039;)) continue;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get the parameter value (as string) and output it as either&lt;br /&gt;
&amp;lt;tt&amp;gt;key=value&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, depending on the&lt;br /&gt;
&amp;lt;tt&amp;gt;parform&amp;lt;/tt&amp;gt; parameter.  &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
	string = sf_histstring(in,key);&lt;br /&gt;
	if (NULL == string) {&lt;br /&gt;
	    sf_warning(&amp;quot;No key %s&amp;quot;,key);&lt;br /&gt;
	} else {&lt;br /&gt;
	    if (parform) printf (&amp;quot;%s=&amp;quot;,key);&lt;br /&gt;
	    printf(&amp;quot;%s\n&amp;quot;,string);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheadercut==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Zero a portion of a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadercut mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array of size n2.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; is close to &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; but instead&lt;br /&gt;
of windowing the dataset, it fills the traces specified by the header&lt;br /&gt;
mask with zeroes. The size of the input data is preserved.&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for &lt;br /&gt;
zeroing every other trace in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a mask with alternating ones and zeros using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 mag=1 | sfdd type=int &amp;gt; ones.rsf&lt;br /&gt;
bash$ sfspike n1=5 mag=0 | sfdd type=int &amp;gt; zeros.rsf&lt;br /&gt;
bash$ sfinterleave axis=1 ones.rsf zeros.rsf &amp;gt; mask.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; mask.rsf&lt;br /&gt;
   0:    1    0    1    0    1    0    1    0    1    0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, &amp;lt;tt&amp;gt;sfheadercut&amp;lt;/tt&amp;gt; zeros the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfheadercut &amp;lt; input.rsf mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; output.rsf &lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             0            0            0            0            0&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             0            0            0            0            0&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfheadersort==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Sort a dataset according to a header key. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadersort &amp;lt; in.rsf &amp;gt; out.rsf head=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;head=&#039;&#039;&#039; ||   || 	header file&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is used to sort traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; for randomly shuffling traces in the input&lt;br /&gt;
file. First, let us create an input file with seven traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=7 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with seven header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=7 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:       0.05256      -0.2879       0.1487       0.4097       0.1548&lt;br /&gt;
   5:        0.4501       0.2836&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally, we&lt;br /&gt;
apply &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; to shuffle the input traces.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheadersort head=random.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             5            5            5            5            5&lt;br /&gt;
  20:             7            7            7            7            7&lt;br /&gt;
  25:             4            4            4            4            4&lt;br /&gt;
  30:             6            6            6            6            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As expected, the order of traces in the output file corresponds to the&lt;br /&gt;
order of values in the header. Thanks to the separation between&lt;br /&gt;
headers and data, the operation of &amp;lt;tt&amp;gt;sfheadersort&amp;lt;/tt&amp;gt; is optimally&lt;br /&gt;
efficient. It first sorts the headers and only then accesses the data,&lt;br /&gt;
reading each data trace only once.&lt;br /&gt;
&lt;br /&gt;
==sfheaderwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a dataset based on a header mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderwindow mask=head.rsf &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;The input data is a collection of traces n1xn2,&amp;lt;br&amp;gt;mask is an integer array os size n2, windowed is n1xm2,&amp;lt;br&amp;gt;where m2 is the number of nonzero elements in mask.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is used to window traces in the input file&lt;br /&gt;
according to trace header information. &lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; for randomly&lt;br /&gt;
selecting part of the traces in the input file. First, let us create&lt;br /&gt;
an input file with ten traces:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 n2=10 output=x2+1 &amp;gt; input.rsf&lt;br /&gt;
bash$ &amp;lt; input.rsf sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             3            3            3            3            3&lt;br /&gt;
  15:             4            4            4            4            4&lt;br /&gt;
  20:             5            5            5            5            5&lt;br /&gt;
  25:             6            6            6            6            6&lt;br /&gt;
  30:             7            7            7            7            7&lt;br /&gt;
  35:             8            8            8            8            8&lt;br /&gt;
  40:             9            9            9            9            9&lt;br /&gt;
  45:            10           10           10           10           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we can create a random file with ten header values using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 | sfnoise rep=y type=n &amp;gt; random.rsf&lt;br /&gt;
bash$ &amp;lt; random.rsf sfdisfil&lt;br /&gt;
   0:     -0.005768      0.02258     -0.04331      -0.4129      -0.3909&lt;br /&gt;
   5:      -0.03582       0.4595      -0.3326        0.498      -0.3517&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you reproduce this example, your numbers will most likely be different,&lt;br /&gt;
because, in the absence of &amp;lt;tt&amp;gt;seed=&amp;lt;/tt&amp;gt; parameter, &amp;lt;tt&amp;gt;sfnoise&amp;lt;/tt&amp;gt;&lt;br /&gt;
uses a random seed value to generate pseudo-random numbers. Finally,&lt;br /&gt;
we apply &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; to window the input traces selecting&lt;br /&gt;
only those for which the header is greater than zero.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; random.rsf sfmask min=0 &amp;gt; mask.rsf&lt;br /&gt;
bash$ &amp;lt; mask.rsf sfdisfil&lt;br /&gt;
   0:    0    1    0    0    0    0    1    0    1    0&lt;br /&gt;
bash$ &amp;lt; input.rsf sfheaderwindow mask=mask.rsf &amp;gt; output.rsf&lt;br /&gt;
bash$ &amp;lt; output.rsf sfdisfil&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             7            7            7            7            7&lt;br /&gt;
  10:             9            9            9            9            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, only three traces are selected for the output. Thanks to&lt;br /&gt;
the separation between headers and data, the operation of&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; is optimally efficient. &lt;br /&gt;
&lt;br /&gt;
==sfin==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display basic information about RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfin info=y check=2. trail=y file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | n1,n2,... are data dimensions&amp;lt;br&amp;gt;o1,o2,... are axis origins&amp;lt;br&amp;gt;d1,d2,... are axis sampling intervals&amp;lt;br&amp;gt;label1,label2,... are axis labels&amp;lt;br&amp;gt;unit1,unit2,... are axis units&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;check=2.&#039;&#039;&#039; ||   || 	Portion of the data (in Mb) to check for zero values.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;info=y&#039;&#039;&#039; ||  [y/n] || 	If n, only display the name of the data file.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trail=y&#039;&#039;&#039; ||  [y/n] || 	If n, skip trailing dimensions of  one&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; is one of the most useful programs for operating with&lt;br /&gt;
RSF files. It produces quick information on the file hypercube&lt;br /&gt;
dimensions and checks the consistency of the associated data file.&lt;br /&gt;
Here is an example. Let us create an RSF file and examine it with &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=20 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=100         d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
        2000 elements 8000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; reports the following information:&lt;br /&gt;
  &lt;br /&gt;
*location of the data file (&amp;lt;tt&amp;gt;/tmp/spike.rsf\@&amp;lt;/tt&amp;gt;) &lt;br /&gt;
*element size (4 bytes) &lt;br /&gt;
*element type (floating point) &lt;br /&gt;
*element form (native) &lt;br /&gt;
*hypercube dimensions (100 by 20) &lt;br /&gt;
*axes scale (0.004 and 0.1) &lt;br /&gt;
*axes origin (0 and 0) &lt;br /&gt;
*axes labels &lt;br /&gt;
*axes units &lt;br /&gt;
*total number of elements &lt;br /&gt;
*total number of bytes in the data file &lt;br /&gt;
Suppose that the file got corrupted by a buggy program and reports&lt;br /&gt;
incorrect dimensions. The &amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; program should be able to&lt;br /&gt;
catch the discrepancy.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ echo n2=100 &amp;gt;&amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf &amp;gt; /dev/null&lt;br /&gt;
sfin:           Actually 8000 bytes, 20% of expected.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfin&amp;lt;/tt&amp;gt; also checks the first records in the file for zeros. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=100 n2=100 k2=99 &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 32768 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The number of bytes to check is adjustable&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike2.rsf check=0.01 &amp;gt;/dev/null&lt;br /&gt;
sfin: The first 16384 bytes are all zeros&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can also output only the location of the data file. This is&lt;br /&gt;
sometimes handy in scripts.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin spike.rsf spike2.rsf info=n&lt;br /&gt;
/tmp/spike.rsf@ /tmp/spike2.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
An alternative is to use &amp;lt;tt&amp;gt;sfget&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfget parform=n in &amp;lt; spike.rsf&lt;br /&gt;
/tmp/spike.rsf@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To actually eliminate annoying trailing dimensions of length one (not just stop displaying them with &amp;lt;tt&amp;gt;trail=n&amp;lt;/tt&amp;gt;), you may use &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt;. Example for eliminating axis 6:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sed -i &#039;s/n6=1//g&#039; file.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfinterleave==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Combine several datasets by interleaving.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfinterleave &amp;gt; out.rsf axis=3 [&amp;lt; file0.rsf] file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=3&#039;&#039;&#039; ||   || 	Axis for interleaving&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfinterleave&amp;lt;/tt&amp;gt; combines two or more datasets by interleaving them on one&lt;br /&gt;
of the axes. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=5 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ sfscale &amp;lt; one.rsf dscale=2 &amp;gt; two.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; two.rsf&lt;br /&gt;
   0:             2            2            2            2            2&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             2            2            2            2            2&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             2            2            2            2            2&lt;br /&gt;
bash$ sfinterleave one.rsf two.rsf axis=1 | sfdisfil&lt;br /&gt;
   0:             1            2            1            2            1&lt;br /&gt;
   5:             2            1            2            1            2&lt;br /&gt;
  10:             1            2            1            2            1&lt;br /&gt;
  15:             2            1            2            1            2&lt;br /&gt;
  20:             1            2            1            2            1&lt;br /&gt;
  25:             2            1            2            1            2&lt;br /&gt;
  30:             1            2            1            2            1&lt;br /&gt;
  35:             2            1            2            1            2&lt;br /&gt;
  40:             1            2            1            2            1&lt;br /&gt;
  45:             2            1            2            1            2&lt;br /&gt;
bash$ sfinterleave &amp;lt; one.rsf two.rsf axis=2 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             2            2            2            2            2&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             2            2            2            2            2&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
  25:             2            2            2            2            2&lt;br /&gt;
  30:             1            1            1            1            1&lt;br /&gt;
  35:             2            2            2            2            2&lt;br /&gt;
  40:             1            1            1            1            1&lt;br /&gt;
  45:             2            2            2            2            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmask==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Create a mask.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmask &amp;lt; in.rsf &amp;gt; out.rsf min=-FLT_MAX max=+FLT_MAX&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Mask is an integer data with ones and zeros. &amp;lt;br&amp;gt;Ones correspond to input values between min and max.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;The output can be used with sfheaderwindow.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=+FLT_MAX&#039;&#039;&#039; ||   || 	maximum header value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=-FLT_MAX&#039;&#039;&#039; ||   || 	minimum header value&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmask&amp;lt;/tt&amp;gt; creates an integer output of ones and zeros comparing&lt;br /&gt;
the values of the input data to specified &amp;lt;tt&amp;gt;min=&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;max=&amp;lt;/tt&amp;gt; parameters. It is useful for &amp;lt;tt&amp;gt;sfheaderwindow&amp;lt;/tt&amp;gt; and&lt;br /&gt;
in many other applications. Here is a quick example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 output=&amp;quot;sin(x1)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfdisfil&lt;br /&gt;
   0:             0       0.8415       0.9093       0.1411      -0.7568&lt;br /&gt;
   5:       -0.9589      -0.2794        0.657       0.9894       0.4121&lt;br /&gt;
bash$ &amp;lt; sin.rsf sfmask min=-0.5 max=0.5 | sfdisfil&lt;br /&gt;
   0:    1    0    0    1    0    0    1    0    0    1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfmath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations on data files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfmath &amp;gt; out.rsf type= unit= output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs, conj (for complex data).&amp;lt;br&amp;gt;                 &amp;lt;br&amp;gt;sfmath will work on float or complex data, but all the input and output&amp;lt;br&amp;gt;files must be of the same data type.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An alternative to sfmath is sfadd, which may be more efficient, but is&amp;lt;br&amp;gt;less versatile.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Examples:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfmath x=file1.rsf y=file2.rsf power=file3.rsf output=&#039;sin((x+2*y)^power)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath &amp;lt; file1.rsf tau=file2.rsf output=&#039;exp(tau*input)&#039; &amp;gt; out.rsf&amp;lt;br&amp;gt;sfmath n1=100 type=complex output=&amp;quot;exp(I*x1)&amp;quot; &amp;gt; out.rsf&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Mathematical description of the output&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;type=&#039;&#039;&#039; ||   || 	output data type [float,complex]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt; is a versatile program for mathematical operations&lt;br /&gt;
with RSF files. It can operate with several input file, all of the&lt;br /&gt;
same dimensions and data type. The data type can be real (floating&lt;br /&gt;
point) or complex. Here is an example that demonstrates several&lt;br /&gt;
features of &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=629 d1=0.01 o1=0 n2=40 d2=1 o2=5 \&lt;br /&gt;
output=&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot; &amp;gt; rad.rsf&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfrtoc | sfmath output=&amp;quot;input*exp(I*x1)&amp;quot; &amp;gt; rose.rsf&lt;br /&gt;
bash$ &amp;lt; rose.rsf sfgraph title=Rose screenratio=1 wantaxis=n | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first line creates a 2-D dataset that consists of 40 traces 629&lt;br /&gt;
samples each. The values of the data are computed with the formula&lt;br /&gt;
&amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;x2*(8+sin(6*x1+x2/10))&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;x1&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
coordinate on the first axis, and &amp;lt;tt&amp;gt;x2&amp;lt;/tt&amp;gt; is the coordinate of the&lt;br /&gt;
second axis. In the second line, we convert the data from real to&lt;br /&gt;
complex using &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; and produce a complex dataset using&lt;br /&gt;
formula &amp;lt;font color=&amp;quot;#cd4b19&amp;quot;&amp;gt;&amp;quot;input*exp(I*x1)&amp;quot;&amp;lt;/font&amp;gt;, where &amp;lt;tt&amp;gt;input&amp;lt;/tt&amp;gt; refers to the&lt;br /&gt;
input file. Finally, we plot the complex data as a collection of&lt;br /&gt;
parametric curves using &amp;lt;tt&amp;gt;sfgraph&amp;lt;/tt&amp;gt; and display the result using&lt;br /&gt;
&amp;lt;tt&amp;gt;sfpen&amp;lt;/tt&amp;gt;.  The plot appearing on your screen should look similar&lt;br /&gt;
to the figure.&lt;br /&gt;
[[Image:rose.png|frame|center|This figure was created with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
One possible alternative to the second line above is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; rad.rsf sfmath output=x1 &amp;gt; ang.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*cos(a)&amp;quot; &amp;gt; cos.rsf&lt;br /&gt;
bash$ sfmath r=rad.rsf a=ang.rsf output=&amp;quot;r*sin(a)&amp;quot; &amp;gt; sin.rsf&lt;br /&gt;
bash$ sfcmplx cos.rsf sin.rsf &amp;gt; rose.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we refer to input files by names (&amp;lt;tt&amp;gt;r&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;a&amp;lt;/tt&amp;gt;) and combine the names in a formula.&lt;br /&gt;
&lt;br /&gt;
==sfpad==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Pad a dataset with zeros.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpad &amp;lt; in.rsf &amp;gt; out.rsf [beg1= beg2= ... end1= end2=... | n1=  n2 = ... | n1out= n2out= ...]&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | begN specifies the number of zeros to add before the beginning of axis N.&amp;lt;br&amp;gt;endN specifies the number of zeros to add after the end of axis N.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Alternatively:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nN or nNout specify the output length of axis N, padding occurs at the end.&amp;lt;br&amp;gt;nN and nNout are equivalent.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;pad&amp;lt;/tt&amp;gt; increases the dimensions of the input dataset by padding&lt;br /&gt;
the data with zeroes. Here are some simple examples.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=5 n2=3 &amp;gt; one.rsf&lt;br /&gt;
bash$ sfdisfil &amp;lt; one.rsf&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad n2=5 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             0            0            0            0            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=2 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             1            1            1            1            1&lt;br /&gt;
bash$ &amp;lt; one.rsf sfpad beg2=1 end2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
  15:             1            1            1            1            1&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
bash$ &amp;lt; one.rsf sfwindow n1=3 | sfpad n1=5 n2=5 beg1=1 beg2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            1            1            1            0&lt;br /&gt;
  10:             0            1            1            1            0&lt;br /&gt;
  15:             0            1            1            1            0&lt;br /&gt;
  20:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can use &amp;lt;tt&amp;gt;sfcat&amp;lt;/tt&amp;gt; to pad data with values other than zeroes.&lt;br /&gt;
&lt;br /&gt;
==sfput==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Input parameters into a header. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfput &amp;lt; in.rsf &amp;gt; out.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is a very simple program. It simply appends parameters&lt;br /&gt;
from the command line to the output RSF file. One can achieve similar&lt;br /&gt;
results with editing by hand or with standard Unix utilities like&lt;br /&gt;
&amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;echo&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;sfput&amp;lt;/tt&amp;gt; is sometimes more&lt;br /&gt;
convenient because it handles input/output operations similarly to&lt;br /&gt;
other regular RSF programs.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 &amp;gt; spike.rsf&lt;br /&gt;
bash$ sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash$ sfput &amp;lt; spike.rsf d1=25 label1=Depth unit1=m &amp;gt; spike2.rsf&lt;br /&gt;
bash$ sfin spike2.rsf&lt;br /&gt;
spike2.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/spike2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=10          d1=25          o1=0          label1=&amp;quot;Depth&amp;quot; unit1=&amp;quot;m&amp;quot;&lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreal==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extract real (sfreal) or imaginary (sfimag) part of a complex dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreal &amp;lt; cmplx.rsf &amp;gt; real.rsf&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt; extracts the real part of a complex type dataset. The&lt;br /&gt;
imaginary part can be extracted with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;, an the real&lt;br /&gt;
and imaginary part can be combined together with &amp;lt;tt&amp;gt;sfcmplx&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Here is a simple example. Let us first create a complex dataset &lt;br /&gt;
with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=10 type=complex output=&amp;quot;(2+I)*x1&amp;quot; &amp;gt; cmplx.rsf&lt;br /&gt;
bash$ fdisfil &amp;lt; cmplx.rsf&lt;br /&gt;
   0:          0,         0i         2,         1i         4,         2i&lt;br /&gt;
   3:          6,         3i         8,         4i        10,         5i&lt;br /&gt;
   6:         12,         6i        14,         7i        16,         8i&lt;br /&gt;
   9:         18,         9i&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the real part with &amp;lt;tt&amp;gt;sfreal&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfreal &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            2            4            6            8&lt;br /&gt;
   5:            10           12           14           16           18&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extracting the imaginary part with &amp;lt;tt&amp;gt;sfimag&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfimag &amp;lt; cmplx.rsf | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             5            6            7            8            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfreverse==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Reverse one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfreverse &amp;lt; in.rsf &amp;gt; out.rsf which=-1 verb=false memsize=sf_memsize() opt=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;opt=&#039;&#039;&#039; ||   || 	If y, change o and d parameters on the reversed axis;&lt;br /&gt;
:if i, don&#039;t change o and d&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;which=-1&#039;&#039;&#039; ||   || 	Which axis to reverse.&lt;br /&gt;
:To reverse a given axis, start with 0,&lt;br /&gt;
:add 1 to number to reverse n1 dimension,&lt;br /&gt;
:add 2 to number to reverse n2 dimension,&lt;br /&gt;
:add 4 to number to reverse n3 dimension, etc.&lt;br /&gt;
:Thus, which=7 would reverse the first three dimensions,&lt;br /&gt;
:which=5 just n1 and n3, etc.&lt;br /&gt;
:which=0 will just pass the input on through unchanged.&lt;br /&gt;
|}&lt;br /&gt;
Here is an example of using &amp;lt;tt&amp;gt;sfreverse&amp;lt;/tt&amp;gt;. First, let us create a&lt;br /&gt;
2-D dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash$ &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the first axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfdisfil&lt;br /&gt;
   0:             4            3            2            1            0&lt;br /&gt;
   5:             5            4            3            2            1&lt;br /&gt;
  10:             6            5            4            3            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=2 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Reversing both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=3 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;which=&amp;lt;/tt&amp;gt; parameter controls the axes that are&lt;br /&gt;
being reversed by encoding them into one number.&lt;br /&gt;
When an axis is reversed, what happens with its axis origin and&lt;br /&gt;
sampling parameters? This behavior is controlled by &amp;lt;tt&amp;gt;opt=&amp;lt;/tt&amp;gt;. In&lt;br /&gt;
our example,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfget n1 o1 d1&lt;br /&gt;
n1=5&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 | sfget o1 d1&lt;br /&gt;
o1=4&lt;br /&gt;
d1=-1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The default behavior (equivalent to &amp;lt;tt&amp;gt;opt=y&amp;lt;/tt&amp;gt;) puts the origin&lt;br /&gt;
&amp;lt;tt&amp;gt;o1&amp;lt;/tt&amp;gt; at the end of the axis and reverses the sampling parameter&lt;br /&gt;
&amp;lt;tt&amp;gt;d1&amp;lt;/tt&amp;gt;.  Using &amp;lt;tt&amp;gt;opt=n&amp;lt;/tt&amp;gt; preserves the sampling but reverses&lt;br /&gt;
the origin.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=n | sfget o1 d1&lt;br /&gt;
o1=-4&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Using &amp;lt;tt&amp;gt;opt=i&amp;lt;/tt&amp;gt; preserves both the sampling and the origin while&lt;br /&gt;
reversing the axis.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; test.rsf sfreverse which=1 opt=i | sfget o1 d1&lt;br /&gt;
o1=0&lt;br /&gt;
d1=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
One of the three possible behaviors may be desirable depending on the&lt;br /&gt;
application.&lt;br /&gt;
&lt;br /&gt;
==sfrm==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Remove RSF files together with their data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrm file1.rsf [file2.rsf ...] [-i] [-v] [-f] &lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Mimics the standard Unix rm command.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also: sfmv, sfcp.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; is a program for removing RSF files. Its arguments mimic&lt;br /&gt;
the arguments of the standard Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt; utility: &amp;lt;tt&amp;gt;-v&amp;lt;/tt&amp;gt;&lt;br /&gt;
for verbosity, &amp;lt;tt&amp;gt;-i&amp;lt;/tt&amp;gt; for interactive inquiry, &amp;lt;tt&amp;gt;-f&amp;lt;/tt&amp;gt; for&lt;br /&gt;
force removal of suspicious files. Unlike the Unix &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; removes both the RSF header files and the binary files&lt;br /&gt;
that the headers point to. &lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 &amp;gt; spike.rsf datapath=./&lt;br /&gt;
bash&amp;amp;#36; sfget in &amp;lt; spike.rsf&lt;br /&gt;
in=./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
spike.rsf  spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; sfrm -v spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing header spike.rsf&lt;br /&gt;
sfrm: sf_rm: Removing data ./spike.rsf@&lt;br /&gt;
bash&amp;amp;#36; ls spike*&lt;br /&gt;
ls: No match.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sfrotate==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Rotate a portion of one or more axes in the data hypercube. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrotate &amp;lt; in.rsf &amp;gt; out.rsf verb=n memsize=sf_memsize() rot#=(0,0,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rot#=(0,0,...)&#039;&#039;&#039; ||   || 	length of #-th axis that is moved to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt; modifies the input dataset by splitting it into&lt;br /&gt;
parts and putting the parts back in a different order. Here is a quick example.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 d1=1 n2=3 d2=1 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the first axis by putting the last two columns in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=2 | sfdisfil&lt;br /&gt;
   0:             3            4            0            1            2&lt;br /&gt;
   5:             4            5            1            2            3&lt;br /&gt;
  10:             5            6            2            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating the second axis by putting the last row in front:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot2=1 | sfdisfil&lt;br /&gt;
   0:             2            3            4            5            6&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Rotating both the first and the second axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfrotate rot1=3 rot2=1 | sfdisfil&lt;br /&gt;
   0:             4            5            6            2            3&lt;br /&gt;
   5:             2            3            4            0            1&lt;br /&gt;
  10:             3            4            5            1            2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The transformation is shown schematically in Figure~(fig:rotate).&lt;br /&gt;
[[Image:rotate.png|frame|center|Schematic transformation of data with &amp;lt;tt&amp;gt;sfrotate&amp;lt;/tt&amp;gt;.]]&lt;br /&gt;
&lt;br /&gt;
==sfrtoc==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert real data to complex (by adding zero imaginary part).&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfrtoc &amp;lt; real.rsf &amp;gt; cmplx.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;See also: sfcmplx&lt;br /&gt;
|}&lt;br /&gt;
The input to &amp;lt;tt&amp;gt;sfrtoc&amp;lt;/tt&amp;gt; can be any &amp;lt;tt&amp;gt;type=float&amp;lt;/tt&amp;gt; dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfspike n1=10 n2=20 n3=30 &amp;gt;real.rsf&lt;br /&gt;
bash$ sfin real.rsf&lt;br /&gt;
real.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/real.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output dataset will have &amp;lt;tt&amp;gt;type=complex&amp;lt;/tt&amp;gt;, and its binary will be twice the size of the input:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt;real.rsf sfrtoc &amp;gt;complex.rsf&lt;br /&gt;
bash$ sfin complex.rsf &lt;br /&gt;
complex.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/complex.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 48000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfscale==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Scale data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfscale &amp;lt; in.rsf &amp;gt; out.rsf axis=0 rscale=0. dscale=1.&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;To scale by a constant factor, you can also use sfmath or sfheadermath.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=0&#039;&#039;&#039; ||   || 	Scale by maximum in the dimensions up to this axis.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dscale=1.&#039;&#039;&#039; ||   || 	Scale by this factor (works if rscale=0)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;rscale=0.&#039;&#039;&#039; ||   || 	Scale by this factor.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfscale&amp;lt;/tt&amp;gt; scales the input dataset by a factor. Here&lt;br /&gt;
are some simple examples. First, let us create a test dataset.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil   &lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Scale every data point by 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale dscale=2 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
   5:             4            8           12           16           20&lt;br /&gt;
  10:             6           12           18           24           30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide every trace by its maximum value:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=1 | sfdisfil&lt;br /&gt;
   0:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
   5:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Divide by the maximum value in the whole 2-D dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfscale axis=2 | sfdisfil&lt;br /&gt;
   0:       0.06667       0.1333          0.2       0.2667       0.3333&lt;br /&gt;
   5:        0.1333       0.2667          0.4       0.5333       0.6667&lt;br /&gt;
  10:           0.2          0.4          0.6          0.8            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The &amp;lt;tt&amp;gt;rscale=&amp;lt;/tt&amp;gt; parameter is synonymous to &amp;lt;tt&amp;gt;dscale=&amp;lt;/tt&amp;gt; except&lt;br /&gt;
when it is equal to zero. With &amp;lt;tt&amp;gt;sfscale dscale=0&amp;lt;/tt&amp;gt;, the dataset gets&lt;br /&gt;
multiplied by zero. If using &amp;lt;tt&amp;gt;rscale=0&amp;lt;/tt&amp;gt;, the other parameters are&lt;br /&gt;
used to define scaling.  Thus, &amp;lt;tt&amp;gt;sfscale rscale=0 axis=1&amp;lt;/tt&amp;gt; is&lt;br /&gt;
equivalent to &amp;lt;tt&amp;gt;sfscale axis=1&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;sfscale rscale=0&amp;lt;/tt&amp;gt;&lt;br /&gt;
is equivalent to &amp;lt;tt&amp;gt;sfscale dscale=1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sfspike==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate simple data: spikes, boxes, planes, constants. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspike &amp;gt; spike.rsf mag= nsp=1 k#=[0,...] l#=[k1,k2,...] p#=[0,...] n#= o#=[0,0,...] d#=[0.004,0.1,0.1,...] label#=[Time,Distance,Distance,...] unit#=[s,km,km,...] title=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Spike positioning is given in samples and starts with 1.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=[0.004,0.1,0.1,...]&#039;&#039;&#039; ||   || 	sampling on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;k#=[0,...]&#039;&#039;&#039; ||   || 	spike starting position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;ints   &#039;&#039; || &#039;&#039;&#039;l#=[k1,k2,...]&#039;&#039;&#039; ||   || 	spike ending position  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=[Time,Distance,Distance,...]&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;mag=&#039;&#039;&#039; ||   || 	spike magnitudes  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=&#039;&#039;&#039; ||   || 	size of #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nsp=1&#039;&#039;&#039; ||   || 	Number of spikes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o#=[0,0,...]&#039;&#039;&#039; ||   || 	origin on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;p#=[0,...]&#039;&#039;&#039; ||   || 	spike inclination (in samples)  [nsp]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || 	title for plots&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=[s,km,km,...]&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; takes no input and generates an output with&lt;br /&gt;
&amp;quot;spikes&amp;quot;. It is an easy way to create data. Here is an example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 k2=1 | sfdisfil&lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The spike location is specified by parameters &amp;lt;tt&amp;gt;k1=4&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;k2=1&amp;lt;/tt&amp;gt;. Note that the locations are numbered starting from 1. &lt;br /&gt;
If one of the parameters is omitted or given the value of zero, the &lt;br /&gt;
spike in the corresponding direction becomes a plane:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=4 | sfdisfil   &lt;br /&gt;
   0:             0            0            0            1            0&lt;br /&gt;
   5:             0            0            0            1            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If no spike parameters are given, the whole dataset is filled with ones:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 | sfdisfil&lt;br /&gt;
   0:             1            1            1            1            1&lt;br /&gt;
   5:             1            1            1            1            1&lt;br /&gt;
  10:             1            1            1            1            1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create several spikes, use the &amp;lt;tt&amp;gt;nsp=&amp;lt;/tt&amp;gt; parameter and give a comma-separated list of values to &amp;lt;tt&amp;gt;k#=&amp;lt;/tt&amp;gt; arguments:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the number of values in the list is smaller than &amp;lt;tt&amp;gt;nsp&amp;lt;/tt&amp;gt;, the&lt;br /&gt;
last value gets repeated, and the spikes add on top of each other,&lt;br /&gt;
creating larger amplitudes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3 k2=1,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            2            0            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The magnitude of the spikes can be controlled explicitly with the&lt;br /&gt;
&amp;lt;tt&amp;gt;mag=&amp;lt;/tt&amp;gt; parameter:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 nsp=3 k1=1,3,4 k2=1,2,3 mag=1,4,2 | sfdisfil&lt;br /&gt;
   0:             1            0            0            0            0&lt;br /&gt;
   5:             0            0            4            0            0&lt;br /&gt;
  10:             0            0            0            2            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can create boxes instead of spikes by using &amp;lt;tt&amp;gt;l#=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 l1=4 k2=2 mag=8 | sfdisfil&lt;br /&gt;
   0:             0            0            0            0            0&lt;br /&gt;
   5:             0            8            8            8            0&lt;br /&gt;
  10:             0            0            0            0            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, &amp;lt;tt&amp;gt;k1=2&amp;lt;/tt&amp;gt; specifies the box start, and &amp;lt;tt&amp;gt;l1=4&amp;lt;/tt&amp;gt;&lt;br /&gt;
specifies the box end.&lt;br /&gt;
Finally, multi-dimensional planes can be given an inclination by using &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=1 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0            0            1            0            0&lt;br /&gt;
  10:             0            0            0            1            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; interprets the &amp;lt;tt&amp;gt;p#=&amp;lt;/tt&amp;gt; parameters in stepout from sample to sample, not in terms of axes units (i.e. s/m). &lt;br /&gt;
&lt;br /&gt;
More than one p parameter can be specified. In this case, a (hyper) plane will be created.&lt;br /&gt;
&lt;br /&gt;
When the inclination value is not integer, simple linear interpolation is used:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 k1=2 p2=0.7 | sfdisfil&lt;br /&gt;
   0:             0            1            0            0            0&lt;br /&gt;
   5:             0          0.3          0.7            0            0&lt;br /&gt;
  10:             0            0          0.6          0.4            0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspike&amp;lt;/tt&amp;gt; supplies default dimensions and labels to all axis:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see, the first axis is assumed to be time, with sampling of&lt;br /&gt;
&amp;lt;math&amp;gt;0.004&amp;lt;/math&amp;gt; seconds. All other axes are assumed to be distance, with&lt;br /&gt;
sampling of &amp;lt;math&amp;gt;0.1&amp;lt;/math&amp;gt; kilometers. All these parameters can be changed on&lt;br /&gt;
the command line.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=5 n2=3 n3=4 label3=Offset unit3=ft d3=20 &amp;gt; spike.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=3           d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=4           d3=20          o3=0          label3=&amp;quot;Offset&amp;quot; unit3=&amp;quot;ft&amp;quot; &lt;br /&gt;
	60 elements 240 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfspray==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Extend a dataset by duplicating in the specified axis dimension.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfspray &amp;lt; in.rsf &amp;gt; out.rsf axis=2 n= d= o= label= unit=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |    This operation is adjoint to sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to spray&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d=&#039;&#039;&#039; ||   || 	Sampling of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	Label of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n=&#039;&#039;&#039; ||   || 	Size of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o=&#039;&#039;&#039; ||   || 	Origin of the newly created dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	Units of the newly created dimension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; extends the input hypercube by replicating the data&lt;br /&gt;
in one of the dimensions. The output dataset acquires one additional&lt;br /&gt;
dimension. Here is an example:&lt;br /&gt;
Start with a 2-D dataset&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=2 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test.rsf&lt;br /&gt;
test.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Extend the data in the second dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=2 n=3 &amp;gt; test2.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test2.rsf&lt;br /&gt;
test2.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test2.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=3           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=1           o3=0          &lt;br /&gt;
        30 elements 120 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test2.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             0            1            2            3            4&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
  20:             1            2            3            4            5&lt;br /&gt;
  25:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is three-dimensional, with traces from the original&lt;br /&gt;
data duplicated along the second axis.&lt;br /&gt;
Extend the data in the third dimension&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfspray axis=3 n=2 &amp;gt; test3.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin test3.rsf&lt;br /&gt;
test3.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/test3.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          &lt;br /&gt;
    n2=2           d2=1           o2=0          &lt;br /&gt;
    n3=2           d3=?           o3=?          &lt;br /&gt;
        20 elements 80 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test3.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             0            1            2            3            4&lt;br /&gt;
  15:             1            2            3            4            5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The output is also three-dimensional, with the original data replicated&lt;br /&gt;
along the third axis.&lt;br /&gt;
&lt;br /&gt;
==sfstack==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stack a dataset over one of the dimensions.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstack &amp;lt; in.rsf &amp;gt; out.rsf axis=2 rms=n norm=y min=n max=n&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;This operation is adjoint to sfspray.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axis=2&#039;&#039;&#039; ||   || 	which axis to stack&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;max=n&#039;&#039;&#039; ||  [y/n] || 	If y, find maximum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;min=n&#039;&#039;&#039; ||  [y/n] || 	If y, find minimum instead of stack.  Ignores rms and norm.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	If y, normalize by fold.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rms=n&#039;&#039;&#039; ||  [y/n] || 	If y, compute the root-mean-square instead of stack.&lt;br /&gt;
|}&lt;br /&gt;
While &amp;lt;tt&amp;gt;sfspray&amp;lt;/tt&amp;gt; adds a dimension to a hypercube,&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; effectively removes one of the dimensions by stacking&lt;br /&gt;
over it. Here are some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
   5:             1            2            3            4            5&lt;br /&gt;
  10:             2            3            4            5            6&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=2 | sfdisfil&lt;br /&gt;
   0:           1.5            2            3            4            5&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 | sfdisfil&lt;br /&gt;
   0:           2.5            3            4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Why is the first value not 1 (in the first case) or 2 (in the second&lt;br /&gt;
case)? By default, &amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; normalizes the stack by the fold&lt;br /&gt;
(the number of non-zero entries). To avoid normalization, use&lt;br /&gt;
&amp;lt;tt&amp;gt;norm=n&amp;lt;/tt&amp;gt;, as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack norm=n | sfdisfil &lt;br /&gt;
   0:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstack&amp;lt;/tt&amp;gt; can also compute root-mean-square values as &lt;br /&gt;
well as minimum and maximum values.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack rms=y | sfdisfil&lt;br /&gt;
   0:         1.581         2.16        3.109        4.082        5.066&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack min=y | sfdisfil&lt;br /&gt;
   0:             0            1            2            3            4&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfstack axis=1 max=y | sfdisfil &lt;br /&gt;
   0:             4            5            6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sftransp==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Transpose two axes in a dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sftransp &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() plane=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;If you get a &amp;quot;Cannot allocate memory&amp;quot; error, give the program a&amp;lt;br&amp;gt;memsize=1 command-line parameter to force out-of-core operation.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plane=&#039;&#039;&#039; ||   || 	Two-digit number with axes to transpose. The default is 12&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; program transposes the input hypercube&lt;br /&gt;
exchanging the two axes specified by the &amp;lt;b&amp;gt;plane=&amp;lt;/b&amp;gt; parameter. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=10 n2=20 n3=30 &amp;gt; orig123.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin orig123.rsf &lt;br /&gt;
orig123.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/orig123.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=30          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=23 &amp;gt;out132.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out132.rsf &lt;br /&gt;
out132.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=30          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=20          d3=0.1         o3=0          label3=&amp;quot;Distance&amp;quot; unit3=&amp;quot;km&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt;orig123.rsf sftransp plane=13 &amp;gt;out321.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin out321.rsf &lt;br /&gt;
out321.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/out132.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=30          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=20          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
    n3=10          d3=0.004       o3=0          label3=&amp;quot;Time&amp;quot; unit3=&amp;quot;s&amp;quot; &lt;br /&gt;
        6000 elements 24000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt; tries to fit the dataset in memory to transpose it&lt;br /&gt;
there but, if not enough memory is available, it performs a slower&lt;br /&gt;
transpose out of core using disk operations. You can control the&lt;br /&gt;
amount of available memory using the &amp;lt;b&amp;gt;memsize=&amp;lt;/b&amp;gt; parameter or&lt;br /&gt;
the &amp;lt;b&amp;gt;RSFMEMSIZE&amp;lt;/b&amp;gt; environmental variable.&lt;br /&gt;
&lt;br /&gt;
==sfwindow==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Window a portion of the dataset. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwindow &amp;lt; in.rsf &amp;gt; out.rsf verb=n squeeze=y j#=(1,...) d#=(d1,d2,...) f#=(0,...) min#=(o1,o2,,...) n#=(0,...) max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d#=(d1,d2,...)&#039;&#039;&#039; ||   || 	sampling in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;f#=(0,...)&#039;&#039;&#039; ||   || 	window start in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;j#=(1,...)&#039;&#039;&#039; ||   || 	jump in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max#=(o1+(n1-1)*d1,o2+(n1-1)*d2,,...)&#039;&#039;&#039; ||   || 	maximum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min#=(o1,o2,,...)&#039;&#039;&#039; ||   || 	minimum in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n#=(0,...)&#039;&#039;&#039; ||   || 	window size in #-th dimension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;squeeze=y&#039;&#039;&#039; ||  [y/n] || 	if y, squeeze dimensions equal to 1 to the end&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; is used to window a portion of the dataset. Here is&lt;br /&gt;
a quick example: Start by creating some data.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfmath n1=5 n2=3 o1=1 o2=1 output=&amp;quot;x1*x2&amp;quot; &amp;gt; test.rsf&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
  10:             3            6            9           12           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now window the first two rows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n2=2 | sfdisfil&lt;br /&gt;
   0:             1            2            3            4            5&lt;br /&gt;
   5:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the first three columns:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow n1=3 | sfdisfil&lt;br /&gt;
   0:             1            2            3            2            4&lt;br /&gt;
   5:             6            3            6            9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window the middle row:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             2            4            6            8           10&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can interpret the &amp;lt;b&amp;gt;f#&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;n#&amp;lt;/b&amp;gt; parameters as&lt;br /&gt;
meaning &amp;quot;skip that many rows/columns&amp;quot; and &amp;quot;select that many&lt;br /&gt;
rows/columns&amp;quot; correspondingly. Window the middle point in the dataset:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow f1=2 n1=1 f2=1 n2=1 | sfdisfil&lt;br /&gt;
   0:             6&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every other column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=2 | sfdisfil&lt;br /&gt;
   0:             1            3            5            2            6&lt;br /&gt;
   5:            10            3            9           15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Window every third column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; test.rsf sfwindow j1=3 | sfdisfil&lt;br /&gt;
   0:             1            4            2            8            3&lt;br /&gt;
   5:            12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternatively, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; can use the minimum and maximum&lt;br /&gt;
parameters to select a window. In the following example, we are&lt;br /&gt;
creating a dataset with &amp;lt;b&amp;gt;sfspike&amp;lt;/b&amp;gt; and then windowing a portion of it&lt;br /&gt;
between 1 and 2 seconds in time and sampled at 8 miliseconds.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; sfspike n1=1000 n2=10 &amp;gt; spike.rsf         &lt;br /&gt;
bash&amp;amp;#36; sfin spike.rsf&lt;br /&gt;
spike.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/spike.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1000        d1=0.004       o1=0          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10000 elements 40000 bytes&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow min1=1 max1=2 d1=0.008 &amp;gt; window.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin window.rsf&lt;br /&gt;
window.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/window.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=126         d1=0.008       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        1260 elements 5040 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
By default, &amp;lt;b&amp;gt;sfwindow&amp;lt;/b&amp;gt; &amp;quot;squeezes&amp;quot; the hypercube dimensions&lt;br /&gt;
that are equal to one toward the end of the dataset. Here is an&lt;br /&gt;
example of taking a time slice:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=10          d1=0.1         o1=0          label1=&amp;quot;Distance&amp;quot; unit1=&amp;quot;km&amp;quot; &lt;br /&gt;
    n2=1           d2=0.004       o2=1          label2=&amp;quot;Time&amp;quot; unit2=&amp;quot;s&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can change this behavior by specifying &amp;lt;b&amp;gt;squeeze=n&amp;lt;/b&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash&amp;amp;#36; &amp;lt; spike.rsf sfwindow n1=1 min1=1 squeeze=n &amp;gt; slice.rsf&lt;br /&gt;
bash&amp;amp;#36; sfin slice.rsf &lt;br /&gt;
slice.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slice.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=1           d1=0.004       o1=1          label1=&amp;quot;Time&amp;quot; unit1=&amp;quot;s&amp;quot; &lt;br /&gt;
    n2=10          d2=0.1         o2=0          label2=&amp;quot;Distance&amp;quot; unit2=&amp;quot;km&amp;quot; &lt;br /&gt;
        10 elements 40 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Seismic programs=&lt;br /&gt;
Programs in this category are specific for operations on seismic data. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/seismic/ system/seismic] in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sffkamo==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Computes Azimuth Move-Out (AMO) operator in the f-k log-stretch domain &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffkamo &amp;lt; in.rsf &amp;gt; out.rsf h1= h2= f1= f2= maxe=10.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f1=&#039;&#039;&#039; ||   || 	input azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;f2=&#039;&#039;&#039; ||   || 	output azimuth in degrees&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h1=&#039;&#039;&#039; ||   || 	input offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;h2=&#039;&#039;&#039; ||   || 	output offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxe=10.&#039;&#039;&#039; ||   || 	stability constraint&lt;br /&gt;
|}&lt;br /&gt;
Sample workflow from [http://m8r.info/RSF/book/sep/fkamo/paper_html/ SEP-110, 63-70 (2001)], with the addition of a bandpass for the input:&lt;br /&gt;
&lt;br /&gt;
Create input -- a (t,x,y) common-offset cube:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike \&lt;br /&gt;
n1=128 o1=0.4 d1=0.0032 k1=65 label1=t \&lt;br /&gt;
n2=256 o2=-1.536 d2=0.012 k2=129 label2=x \&lt;br /&gt;
n3=128 o3=-1.024 d3=0.016 k3=65 label3=y | \&lt;br /&gt;
sfbandpass flo=5 fhi=60 &amp;gt; spikebps.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply log-stretch FFT:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebps.rsf sfstretch rule=L dens=4 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 &amp;gt; spikefft3.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compute AMO operator for a file of the dimensions of &amp;lt;tt&amp;gt;spikefft3.rsf&amp;lt;/tt&amp;gt;. The only information taken from stdin are the n, o, d parameters:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikefft3.rsf sffkamo h2=2 f2=10 h1=1.8 f1=30 &amp;gt;oper.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the operator by multiplication and fft back to (t, mx, my):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikefft3.rsf sfadd mode=prod oper.rsf |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfstretch rule=L dens=4 inv=y &amp;gt; spikeamo.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prepare for 8-bit greyscale visualization:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sfbyte pclip=100 gainpanel=a &amp;gt; spikebyte.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture from the middle of the impulse response:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;spikebyte.rsf sfgrey3 frame1=65 frame2=129 frame3=65 \&lt;br /&gt;
point1=0.333 title=&#039;AMO saddle, no f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Picture illustrating the artifacts (i.e. need for f-k filter):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikebyte.rsf sfgrey3 frame1=65 frame2=97 frame3=97 \&lt;br /&gt;
point1=0.333 title=&#039;No f-k filter&#039; | sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apply the f-k filter and (in this case) visualize:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; spikeamo.rsf sffft1 |\&lt;br /&gt;
sffft3 axis=2 |\&lt;br /&gt;
sffft3 axis=3 |\&lt;br /&gt;
sfdipfilter v1=-2.5 v2=-1.5 v3=1.5 v4=2.5 taper=2 pass=0 dim=3 |\&lt;br /&gt;
sffft3 axis=3 inv=y |\&lt;br /&gt;
sffft3 axis=2 inv=y |\&lt;br /&gt;
sffft1 inv=y |\&lt;br /&gt;
sfbyte pclip=100 gainpanel=a |\&lt;br /&gt;
sfgrey3 frame1=65 frame2=97 frame3=97 point1=0.333 title=&#039;With f-k filter&#039; |\&lt;br /&gt;
sfpen &amp;amp;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==sfheaderattr==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Integer header attributes. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheaderattr &amp;lt; head.rsf&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Only nonzero values are reported.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; examines the contents of a trace header file,&lt;br /&gt;
typically generated by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;. In the example below, we examine&lt;br /&gt;
trace headers in the output of &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt;, a program from Seismic Unix.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
bash$ sfheaderattr &amp;lt; tfile.rsf&lt;br /&gt;
*******************************************&lt;br /&gt;
71 headers, 32 traces&lt;br /&gt;
key[0]=&amp;quot;tracl&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[1]=&amp;quot;tracr&amp;quot;      min[0]=1            max[31]=32          mean=16.5&lt;br /&gt;
key[11]=&amp;quot;offset&amp;quot;    min[0]=400          max[31]=400         mean=400&lt;br /&gt;
key[38]=&amp;quot;ns&amp;quot;        min[0]=64           max[31]=64          mean=64&lt;br /&gt;
key[39]=&amp;quot;dt&amp;quot;        min[0]=4000         max[31]=4000        mean=4000&lt;br /&gt;
*******************************************&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For different standard keywords, a minimum, maximum, and mean values&lt;br /&gt;
are reported unless they are identically zero.  This quick inspection&lt;br /&gt;
can help in identifying meaningful keywords set in the data. The input&lt;br /&gt;
data type must be &amp;lt;tt&amp;gt;int&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfheadermath==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Mathematical operations, possibly on header keys. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfheadermath &amp;lt; in.rsf &amp;gt; out.rsf memsize=sf_memsize() output=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Known functions: cos,  sin,  tan,  acos,  asin,  atan, &amp;lt;br&amp;gt;                 cosh, sinh, tanh, acosh, asinh, atanh,&amp;lt;br&amp;gt;                 exp,  log,  sqrt, abs&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;See also sfmath. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;An addition operation can be performed by sfstack.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;memsize=sf_memsize()&#039;&#039;&#039; ||   || 	Max amount of RAM (in Mb) to be used&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;output=&#039;&#039;&#039; ||   || 	Describes the output in a mathematical notation.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; is a versatile program for mathematical&lt;br /&gt;
operations on rows of the input file. If the input file is an&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; by &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix, the output will be a &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; by&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt; matrix that contains one row made out of mathematical&lt;br /&gt;
operations on the other rows. &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; can identify a row&lt;br /&gt;
by number or by a standard SEGY keyword. The latter is useful for&lt;br /&gt;
processing headers extracted from SEGY or SU files.&lt;br /&gt;
Here is an example. First, we create an SU file with &amp;lt;tt&amp;gt;suplane&amp;lt;/tt&amp;gt; and convert it to RSF using &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ suplane &amp;gt; plane.su&lt;br /&gt;
bash$ sfsegyread tape=plane.su su=y tfile=tfile.rsf &amp;gt; plane.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The trace header information is saved in &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt;. It&lt;br /&gt;
contains 71 headers for 32 traces in integer format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ sfin tfile.rsf&lt;br /&gt;
tfile.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/tfile.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=int form=native&lt;br /&gt;
    n1=71          d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        2272 elements 9088 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Next, we will convert &amp;lt;tt&amp;gt;tfile.rsf&amp;lt;/tt&amp;gt; to a floating-point format&lt;br /&gt;
and run &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt; to create a new header.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bash$ &amp;lt; tfile.rsf sfdd type=float | \&lt;br /&gt;
sfheadermath myheader=1 output=&amp;quot;sqrt(myheader+(2+10*offset^2))&amp;quot; &amp;gt; new.rsf&lt;br /&gt;
bash$ sfin new.rsf&lt;br /&gt;
new.rsf:&lt;br /&gt;
    in=&amp;quot;/tmp/new.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1           d1=?           o1=?&lt;br /&gt;
    n2=32          d2=?           o2=?&lt;br /&gt;
        32 elements 128 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We defined &amp;quot;myheader&amp;quot; as being the row number 1 in the input (note&lt;br /&gt;
that numbering starts with 0) and combined it with &amp;quot;offset&amp;quot;, which&lt;br /&gt;
is a standard SEGY keyword that denotes row number 11 (see the output&lt;br /&gt;
of &amp;lt;tt&amp;gt;sfheaderattr&amp;lt;/tt&amp;gt; above.) A variety of mathematical expressions&lt;br /&gt;
can be defined in the &amp;lt;tt&amp;gt;output=&amp;lt;/tt&amp;gt; string. The expression&lt;br /&gt;
processing engine is shared with &amp;lt;tt&amp;gt;sfmath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==sfsegyheader==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Make a trace header file for segywrite.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyheader &amp;lt; in.rsf &amp;gt; out.rsf n1= d1=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;   Use the output for tfile= argument in segywrite.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=&#039;&#039;&#039; ||   ||      trace sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=&#039;&#039;&#039; ||   ||      number of samples in a trace&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==sfsegyread==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a SEG-Y or SU dataset to RSF.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegyread mask=msk.rsf &amp;gt; out.rsf tfile=hdr.rsf verb=n su= suxdr=n endian=y format=segyformat (bhead) ns=segyns (bhead) tape= read= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Data headers and trace headers are separated from the data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;suread&amp;quot; is equivalent to &amp;quot;segyread su=y&amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;SEGY key names:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracl: trace sequence number within line 0&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracr: trace sequence number within reel 4&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;fldr:     field record number 8 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tracf:    trace number within field record 12 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ep:       energy source point number 16 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdp:      CDP ensemble number 20 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpt:     trace number within CDP ensemble 24 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trid:     trace identification code:&amp;lt;br&amp;gt;1 = seismic data&amp;lt;br&amp;gt;2 = dead&amp;lt;br&amp;gt;3 = dummy&amp;lt;br&amp;gt;4 = time break&amp;lt;br&amp;gt;5 = uphole&amp;lt;br&amp;gt;6 = sweep&amp;lt;br&amp;gt;7 = timing&amp;lt;br&amp;gt;8 = water break&amp;lt;br&amp;gt;9---, N = optional use (N = 32,767) 28 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nvs:      number of vertically summed traces 30 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nhs:      number of horizontally summed traces 32 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;duse:     data use:&amp;lt;br&amp;gt;1 = production&amp;lt;br&amp;gt;2 = test 34&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;offset:   distance from source point to receiver&amp;lt;br&amp;gt;group (negative if opposite to direction&amp;lt;br&amp;gt;in which the line was shot) 36 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gelev:    receiver group elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 40 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;selev:    source elevation from sea level&amp;lt;br&amp;gt;(above sea level is positive) 44 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdepth:   source depth (positive) 48 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gdel:     datum elevation at receiver group 52 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sdel:     datum elevation at source 56 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swdep:    water depth at source 60 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gwdep:    water depth at receiver group 64 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalel:   scale factor for previous 7 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 68 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;scalco:   scale factor for next 4 entries&amp;lt;br&amp;gt;with value plus or minus 10 to the&amp;lt;br&amp;gt;power 0, 1, 2, 3, or 4 (if positive,&amp;lt;br&amp;gt;multiply, if negative divide) 70 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sx:       X source coordinate 72 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sy:       Y source coordinate 76 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gx:       X group coordinate 80 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gy:       Y group coordinate 84 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;counit:   coordinate units code:&amp;lt;br&amp;gt;for previous four entries&amp;lt;br&amp;gt;1 = length (meters or feet)&amp;lt;br&amp;gt;2 = seconds of arc (in this case, the&amp;lt;br&amp;gt;X values are unsigned longitude and the Y values&amp;lt;br&amp;gt;are latitude, a positive value designates&amp;lt;br&amp;gt;the number of seconds east of Greenwich&amp;lt;br&amp;gt;or north of the equator 88 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;wevel:     weathering velocity 90 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;swevel:    subweathering velocity 92 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sut:       uphole time at source 94 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gut:       uphole time at receiver group 96 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sstat:     source static correction 98 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gstat:     group static correction 100 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tstat:     total static applied 102 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;laga:      lag time A, time in ms between end of 240-&amp;lt;br&amp;gt;byte trace identification header and time&amp;lt;br&amp;gt;break, positive if time break occurs after&amp;lt;br&amp;gt;end of header, time break is defined as&amp;lt;br&amp;gt;the initiation pulse which maybe recorded&amp;lt;br&amp;gt;on an auxiliary trace or as otherwise&amp;lt;br&amp;gt;specified by the recording system 104 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lagb:      lag time B, time in ms between the time&amp;lt;br&amp;gt;break and the initiation time of the energy source,&amp;lt;br&amp;gt;may be positive or negative 106 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;delrt:     delay recording time, time in ms between&amp;lt;br&amp;gt;initiation time of energy source and time&amp;lt;br&amp;gt;when recording of data samples begins&amp;lt;br&amp;gt;(for deep water work if recording does not&amp;lt;br&amp;gt;start at zero time) 108 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;muts:      mute time--start 110 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;mute:      mute time--end 112 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;ns:        number of samples in this trace 114 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;dt:        sample interval, in micro-seconds 116 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gain:      gain type of field instruments code:&amp;lt;br&amp;gt;1 = fixed&amp;lt;br&amp;gt;2 = binary&amp;lt;br&amp;gt;3 = floating point&amp;lt;br&amp;gt;4 ---- N = optional use 118 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igc:       instrument gain constant 120 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;igi:       instrument early or initial gain 122 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;corr:      correlated:&amp;lt;br&amp;gt;1 = no&amp;lt;br&amp;gt;2 = yes 124&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfs:       sweep frequency at start 126 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sfe:       sweep frequency at end 128 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;slen:      sweep length in ms 130 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;styp:      sweep type code:&amp;lt;br&amp;gt;1 = linear&amp;lt;br&amp;gt;2 = cos-squared&amp;lt;br&amp;gt;3 = other 132&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stas:      sweep trace length at start in ms 134 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stae:      sweep trace length at end in ms 136 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tatyp:     taper type: 1=linear, 2=cos^2, 3=other 138 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afilf:     alias filter frequency if used 140 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;afils:     alias filter slope 142 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofilf:    notch filter frequency if used 144 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;nofils:    notch filter slope 146 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcf:       low cut frequency if used 148 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcf:       high cut frequncy if used 150 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;lcs:       low cut slope 152 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hcs:       high cut slope 154 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;year:      year data recorded 156 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;day:       day of year 158 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;hour:      hour of day (24 hour clock) 160 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;minute:    minute of hour 162 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sec:       second of minute 164 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;timbas:    time basis code:&amp;lt;br&amp;gt;1 = local&amp;lt;br&amp;gt;2 = GMT&amp;lt;br&amp;gt;3 = other 166&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;trwf:      trace weighting factor, defined as 1/2^N&amp;lt;br&amp;gt;volts for the least sigificant bit 168 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnors:    geophone group number of roll switch&amp;lt;br&amp;gt;position one 170&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnofr:    geophone group number of trace one within&amp;lt;br&amp;gt;original field record 172&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;grnlof:    geophone group number of last trace within&amp;lt;br&amp;gt;original field record 174&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;gaps:      gap size (total number of groups dropped) 176 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;otrav:     overtravel taper code: &amp;lt;br&amp;gt;1 = down (or behind)&amp;lt;br&amp;gt;2 = up (or ahead) 178&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpx:   X coordinate of CDP 180&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;cdpy:   Y coordinate of CDP 184&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;iline:  in-line number 188 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;xline:  cross-line number 192&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shnum:  shotpoint number 196&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;shsca:  shotpoint scalar 200&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tval:   trace value meas. 202&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst4: transduction const 204&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tconst2: transduction const 208&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tunits:  transduction units 210&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;device:  device identifier 212&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;tscalar: time scalar 214&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;stype:   source type 216&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;sendir:  source energy dir. 218&amp;lt;br&amp;gt; &amp;lt;br&amp;gt;unknown: unknown 222&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas4:  source measurement 224&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeas2:  source measurement 228&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;smeasu:  source measurement unit 230 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass1:  unassigned 232&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;unass2:  unassigned 236&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   || 	output binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=y&#039;&#039;&#039; ||  [y/n] || 	Whether to automatically estimate endianness or not&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;format=segyformat (bhead)&#039;&#039;&#039; ||  [1,2,3,5] || 	Data format. The default is taken from binary header.&lt;br /&gt;
:1 is IBM floating point&lt;br /&gt;
:2 is 4-byte integer&lt;br /&gt;
:3 is 2-byte integer&lt;br /&gt;
:5 is IEEE floating point&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   || 	output text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;mask=&#039;&#039;&#039; ||   || 	optional header mask for reading only selected traces (auxiliary input file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ns=segyns (bhead)&#039;&#039;&#039; ||   || 	Number of samples. The default is taken from binary header&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;read=&#039;&#039;&#039; ||   || 	what to read: h - header, d - data, b - both (default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=&#039;&#039;&#039; ||  [y/n] || 	y if input is SU, n if input is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;suxdr=n&#039;&#039;&#039; ||  [y/n] || 	y, SU has XDR support&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   || 	input data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tfile=&#039;&#039;&#039; ||   || 	output trace header file (auxiliary output file name)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The SEG Y format is an [http://en.wikipedia.org/wiki/Open_standard open standard] for the exchange of geophysical data. It is controlled by the non-profit [http://www.seg.org/SEGportalWEBproject/portals/SEG_Online.portal?_nfpb=true&amp;amp;_pageLabel=pg_gen_content&amp;amp;Doc_Url=prod/SEG-Publications/Pub-Yearbook/committees.htm SEG Technical Standards Committee]. There are two versions of this standard: [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev0.pdf rev0] (1975)&amp;lt;ref&amp;gt;Barry, K.M., Cavers, D.A., and Kneale, C.W. 1975. Recommended standards for digital tape formats. &#039;&#039;Geophysics&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, no. 02, 344–352.&amp;lt;/ref&amp;gt; and [http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf rev1] (2002)&amp;lt;ref&amp;gt;Norris, M.W., Faichney, A.K., &#039;&#039;Eds&#039;&#039;. 2001. SEG Y rev1 Data Exchange format. Society of Exploration Geophysicists, Tulsa, OK, 45 pp.&amp;lt;/ref&amp;gt;. The implementation in &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; is a mixture of rev0 (i.e. no checks for Extended Textual Headers) and rev1 ([http://en.wikipedia.org/wiki/IEEE_floating-point_standard IEEE floating point format] allowed for trace data samples).&lt;br /&gt;
&lt;br /&gt;
A SEG-Y file as understood by &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; contains a &amp;quot;Reel Identification Header&amp;quot; (3200 bytes in EBCDIC followed by 400 bytes in a binary encoding), followed by a number of &amp;quot;Trace Blocks&amp;quot;. Each &amp;quot;Trace Block&amp;quot; contains a 240-byte &amp;quot;Trace Header&amp;quot; (binary) followed by &amp;quot;Trace Data&amp;quot; -- a sequence of &amp;lt;tt&amp;gt;ns&amp;lt;/tt&amp;gt; samples. Binary values in both reel headers and trace headers are two&#039;s complement integers, either two bytes or four bytes long. There are no floating-point values defined in the headers. Trace Data samples can have various encodings, either floating point or integer, described further down, but they are all big-endian. To convert from SEG-Y to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will strip the tape reel EBCDIC header and convert it to ASCII, will extract the reel binary header without changing it, and will put the trace headers into one RSF file, and the traces themselves on another.&lt;br /&gt;
&lt;br /&gt;
===SEG-Y Trace Headers===&lt;br /&gt;
In the SEG-Y standard, only the first 180 bytes of the 240-byte trace header are defined; bytes 181-240 are reserved for non-standard header information, and these locations are increasingly used in modern SEG-Y files and its variants. The standard provides for a total of 71 4-byte and 2-byte predefined header words. These 71 standard words have defined lengths and byte offsets, and only these words and byte locations are read using &amp;lt;tt&amp;gt;segyread&amp;lt;/tt&amp;gt; and output to the RSF header file with the &amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; option. The user may remap these predefined keywords to a different byte offsets.&lt;br /&gt;
&lt;br /&gt;
===SU File Format===&lt;br /&gt;
An [http://www.cwp.mines.edu/sututor/node22.html SU file] is nothing more than a SEG-Y file without the reel headers, and with the Trace Data samples in the native encoding of the CPU the file was created on (Attention -- limited portability!). So, to convert from SU to RSF, &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; will just separate headers and traces into two RSF files. &lt;br /&gt;
&lt;br /&gt;
===SEG-Y specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;hfile=&amp;lt;/tt&amp;gt; specifies the name of the file in which the EBCDIC reel header will be put after conversion to ASCII. If you are certain there is no useful information in it, &amp;lt;tt&amp;gt;hfile=/dev/null&amp;lt;/tt&amp;gt; works just fine. If you do not specify anything for this parameter you will get an ASCII file named &amp;lt;tt&amp;gt;header&amp;lt;/tt&amp;gt; in the current directory. If you want to quickly preview this header before running &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt;, use&amp;lt;pre&amp;gt;dd if=input.segy count=40 bs=80 cbs=80 conv=unblock,ascii&amp;lt;/pre&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;bfile=&amp;lt;/tt&amp;gt; specifies name of the file in which the binary reel header (the 400-bytes thing following the 3600-bytes EBCDIC) will be put without any conversion. The default name is &amp;quot;binary&amp;quot;. Unless you have software that knows how to read exactly this special type of file, it will be completely useless, so do &amp;lt;tt&amp;gt;bfile=/dev/null&amp;lt;/tt&amp;gt;&lt;br /&gt;
*&amp;lt;tt&amp;gt;format=&amp;lt;/tt&amp;gt; specifies the format in which the trace data samples are in the SEG-Y input file. This is read from the binary reel header of the SEG-Y file. Valid values are 1(IBM floating point), 2 (4-byte integer), 3 (2-byte integer) and 5 (IEEE floating point). If the input file is SU, the format will be assumed to be the native &amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; format.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;tt&amp;gt;keyname=&amp;lt;/tt&amp;gt; specifies the byte offset to remap a header using the trace header key names shown above. For example, if the CDP locations have been placed in bytes 181-184 instead of the standard 21-24, &amp;lt;tt&amp;gt;cdp=180&amp;lt;/tt&amp;gt; will remap the trace header to that location. &lt;br /&gt;
&lt;br /&gt;
===SU-specific parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;suxdr=&amp;lt;/tt&amp;gt; specifies whether the input file was created with a SU package with XDR support enabled. If you have access to the source code of your SU install (try &amp;lt;tt&amp;gt;$CWPROOT/src&amp;lt;/tt&amp;gt;), type: &amp;lt;tt&amp;gt;grep &#039;XDRFLAG =&#039; $CWPROOT/src/Makefile.config&amp;lt;/tt&amp;gt; and look at the last uncommented entry. If no value is given for &amp;lt;tt&amp;gt;XDRFLAG&amp;lt;/tt&amp;gt;, the package was not compiled with XDR support.&lt;br /&gt;
===Common parameters===&lt;br /&gt;
*&amp;lt;tt&amp;gt;su=&amp;lt;/tt&amp;gt; specifies if the input file is SU or SEG-Y. Default is &amp;lt;tt&amp;gt;su=n&amp;lt;/tt&amp;gt; (SEG-Y file).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; specifies the input data. Stdin could not be used because &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; has to work with tapes, and needs to fseek back and forth through the input file. Thankfully, output is on stdout.&lt;br /&gt;
*&amp;lt;tt&amp;gt;read=&amp;lt;/tt&amp;gt; specifies what parts of the &amp;quot;Trace Blocks&amp;quot; will be read. It can be &amp;lt;tt&amp;gt;read=t&amp;lt;/tt&amp;gt; (only trace data is read), &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; (only trace headers are read) or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt; (both are read).&lt;br /&gt;
*&amp;lt;tt&amp;gt;tfile=&amp;lt;/tt&amp;gt; gives the name of the RSF file to which trace headers are written. Obviously, it should be only specified with &amp;lt;tt&amp;gt;read=h&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;read=b&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;mask=&amp;lt;/tt&amp;gt; is an optional parameter specifying the name of a mask that says which traces will be read. The mask is a 1-D RSF file with integers. The number of samples in the mask is the same as the number of traces in the unmasked SEG-Y. In places corresponding to unwanted traces there should be zeros in the mask.&lt;br /&gt;
*&amp;lt;tt&amp;gt;ns=&amp;lt;/tt&amp;gt; specifies the number of samples in a trace. For SEG-Y files, the default is taken from the binary reel header, and for SU files, from the header of the first trace. This parameter is however critical enough that a command line override was given for it.&lt;br /&gt;
*&amp;lt;tt&amp;gt;verbose=&amp;lt;/tt&amp;gt; is the verbosity flag. Can be &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;.&lt;br /&gt;
*&amp;lt;tt&amp;gt;endian=&amp;lt;/tt&amp;gt; is a y/n flag (default y), specifying whether to automatically estimate or not if samples in the Trace Data blocks are big-endian or little-endian. Try it if you are in trouble and do not know what else to do, otherwise let the automatic estimation do its job.&lt;br /&gt;
&lt;br /&gt;
==sfsegywrite==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert an RSF dataset to SEGY or SU.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsegywrite &amp;lt; in.rsf tfile=hdr.rsf verb=false su=false endian=sf_endian() tape= hfile= bfile=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | &amp;lt;br&amp;gt;Merges trace headers with data.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bfile=&#039;&#039;&#039; ||   ||   input binary data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;endian=sf_endian()&#039;&#039;&#039; ||  [y/n] ||  big/little endian flag. The default is estimated automatically&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;hfile=&#039;&#039;&#039; ||   ||   input text data header file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;su=n&#039;&#039;&#039; ||  [y/n] ||        y if output is SU, n if output is SEGY&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tape=&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] ||   Verbosity flag&lt;br /&gt;
|}&lt;br /&gt;
Please see &amp;lt;tt&amp;gt;sfsegyread&amp;lt;/tt&amp;gt; for a complete description of parameter meanings and background issues. Parameters &amp;lt;tt&amp;gt;bfile&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;hfile&amp;lt;/tt&amp;gt; should only be given values when the desired file is SEG-Y (default). The output file is specified by the &amp;lt;tt&amp;gt;tape=&amp;lt;/tt&amp;gt; tag.&lt;br /&gt;
=Generic programs=&lt;br /&gt;
Programs in this category are general signal and image processing programs. The source files for these programs can be found under [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/system/seismic/ system/generic] in the Madagascar distribution.&lt;br /&gt;
==sfnoise==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Add random noise to the data.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfnoise &amp;lt; in.rsf &amp;gt; out.rsf seed=time(NULL) type=y var= range= mean=0 rep=n&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;mean=0&#039;&#039;&#039; ||   || 	noise mean&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;range=&#039;&#039;&#039; ||   || 	noise range (default=1)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;rep=n&#039;&#039;&#039; ||  [y/n] || 	if y, replace data with noise&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;seed=time(NULL)&#039;&#039;&#039; ||   || 	random seed&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;type=y&#039;&#039;&#039; ||  [y/n] || 	noise distribution, y: normal, n: uniform&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;var=&#039;&#039;&#039; ||   || 	noise variance&lt;br /&gt;
|}&lt;br /&gt;
See the [http://www.ahay.org/rsflog/index.php?/archives/262-Program-of-the-month-sfnoise.html Program of the Month] blog entry.&lt;br /&gt;
&lt;br /&gt;
=Plotting programs (stable)=&lt;br /&gt;
The source files for these programs can be found under&lt;br /&gt;
[http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/plot/main/ plot/main]&lt;br /&gt;
in the Madagascar distribution.&lt;br /&gt;
&lt;br /&gt;
==sfbox==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Draw a balloon-style label.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfbox lab_color=VP_WHITE lab_fat=0 pscale=1. pointer=y reverse=n lat=0. long=90. angle=0. x0=0. y0=0. scale0=1. xt=2. yt=0. x_oval=0. y_oval=0. boxit=y length= scalet= size=.25 label= &amp;gt; out.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;angle=0.&#039;&#039;&#039; ||   || 	longitude of floating label in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;boxit=y&#039;&#039;&#039; ||  [y/n] || 	if y, create a box around text&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_color=VP_WHITE&#039;&#039;&#039; ||   || 	label color&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;lab_fat=0&#039;&#039;&#039; ||   || 	label fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label=&#039;&#039;&#039; ||   || 	text for label&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;lat=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;length=&#039;&#039;&#039; ||   || 	normalization for xt and yt&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;long=90.&#039;&#039;&#039; ||   || 	latitude and longitude of viewpoint in 3-D&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;pointer=y&#039;&#039;&#039; ||  [y/n] || 	if y, create arrow pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pscale=1.&#039;&#039;&#039; ||   || 	scale factor for width of pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;reverse=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scale0=1.&#039;&#039;&#039; ||   || 	scale factor for x0 and y0&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;scalet=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;size=.25&#039;&#039;&#039; ||   || 	text height in inches&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x0=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;x_oval=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xt=2.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y0=0.&#039;&#039;&#039; ||   || 	position of the pointer tip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;y_oval=0.&#039;&#039;&#039; ||   || 	size of the oval around pointer&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yt=0.&#039;&#039;&#039; ||   || 	relative position of text&lt;br /&gt;
|}&lt;br /&gt;
==sfcontour==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Contour plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcontour &amp;lt; in.rsf c= min1=o1 min2=o2 max1=o1+(n1-1)*d1 max2=o2+(n2-1)*d2 nc=50 dc= c0= transp=y minval= maxval= allpos=y barlabel= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=y&#039;&#039;&#039; ||  [y/n] || 	contour positive values only&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;barlabel=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;c=&#039;&#039;&#039; ||   || 	 [nc]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;c0=&#039;&#039;&#039; ||   || 	first contour&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dc=&#039;&#039;&#039; ||   || 	contour increment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max1=o1+(n1-1)*d1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max2=o2+(n2-1)*d2&#039;&#039;&#039; ||   || 	data window to plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min1=o1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min2=o2&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nc=50&#039;&#039;&#039; ||   || 	number of contours&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfdots==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot signal with lollipops.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfdots &amp;lt; in.rsf labels= dots=(n1 &amp;lt;= 130)? 1: 0 seemean=(bool) (n2 &amp;lt;= 30) strings=(bool) (n1 &amp;lt;= 400) connect=1 corners= silk=n gaineach=y labelsz=8 yreverse=n constsep=n seedead=n transp=n xxscale=1. yyscale=1. clip=-1. overlap=0.9 screenratio=VP_SCREEN_RATIO screenht=VP_STANDARD_HEIGHT screenwd=screenhigh / screenratio radius=dd1/3 label1= unit1= title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=-1.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;connect=1&#039;&#039;&#039; ||   || 	connection type: 1 - diagonal, 2 - bar, 4 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;constsep=n&#039;&#039;&#039; ||  [y/n] || 	if y, use constant trace separation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;corners=&#039;&#039;&#039; ||   || 	number of polygon corners (default is 6)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dots=(n1 &amp;lt;= 130)? 1: 0&#039;&#039;&#039; ||   || 	type of dots: 1 - baloon, 0 - no dots, 2 - only for non-zero data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;gaineach=y&#039;&#039;&#039; ||  [y/n] || 	if y, gain each trace independently&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;strings&#039;&#039; || &#039;&#039;&#039;labels=&#039;&#039;&#039; ||   || 	trace labels  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;labelsz=8&#039;&#039;&#039; ||   || 	label size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;overlap=0.9&#039;&#039;&#039; ||   || 	trace overlap&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;radius=dd1/3&#039;&#039;&#039; ||   || 	dot radius&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenht=VP_STANDARD_HEIGHT&#039;&#039;&#039; ||   || 	screen height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenratio=VP_SCREEN_RATIO&#039;&#039;&#039; ||   || 	screen aspect ratio&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;screenwd=screenhigh / screenratio&#039;&#039;&#039; ||   || 	screen width&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seedead=n&#039;&#039;&#039; ||  [y/n] || 	if y, show zero traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=(bool) (n2 &amp;lt;= 30)&#039;&#039;&#039; ||  [y/n] || 	if y, draw axis lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;silk=n&#039;&#039;&#039; ||  [y/n] || 	if y, silky plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;strings=(bool) (n1 &amp;lt;= 400)&#039;&#039;&#039; ||  [y/n] || 	if y, draw strings&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xxscale=1.&#039;&#039;&#039; ||   || 	x scaling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse y axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;yyscale=1.&#039;&#039;&#039; ||   || 	y scaling&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot for surfaces.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph3 &amp;lt; in.rsf orient=1 min= max= point1=0.5 point2=0.5 frame1=0.5*(min+max) frame2=n1-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;frame1=0.5*(min+max)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n1-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;max=&#039;&#039;&#039; ||   || 	maximum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;min=&#039;&#039;&#039; ||   || 	minimum function value&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;orient=1&#039;&#039;&#039; ||   || 	function orientation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|}&lt;br /&gt;
==sfgraph==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Graph plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgraph &amp;lt; in.rsf symbolsz= pclip=100. transp=n symbol= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;symbol=&#039;&#039;&#039; ||   || 	if set, plot with symbols instead of lines&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;floats &#039;&#039; || &#039;&#039;&#039;symbolsz=&#039;&#039;&#039; ||   || 	symbol size (default is 2)  [n2]&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|}&lt;br /&gt;
==sfgrey3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate 3-D cube plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey3 &amp;lt; in.rsf point1=0.5 point2=0.5 frame1=0 frame2=n2-1 frame3=0 movie=0 dframe=1 n1pix=n1/point1+n3/(1.-point1) n2pix=n2/point2+n3/(1.-point2) flat=y scalebar=n minval= maxval= barreverse=n nreserve=8 bar= color= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Requires an &amp;quot;unsigned char&amp;quot; input (the output of sfbyte).&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dframe=1&#039;&#039;&#039; ||   || 	frame increment in a movie&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;flat=y&#039;&#039;&#039; ||  [y/n] || 	if n, display perspective view&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame1=0&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame2=n2-1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;frame3=0&#039;&#039;&#039; ||   || 	frame numbers for cube faces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;movie=0&#039;&#039;&#039; ||   || 	0: no movie, 1: movie over axis 1, 2: axis 2, 3: axis 3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1pix=n1/point1+n3/(1.-point1)&#039;&#039;&#039; ||   || 	number of vertical pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n2pix=n2/point2+n3/(1.-point2)&#039;&#039;&#039; ||   || 	number of horizontal pixels&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point1=0.5&#039;&#039;&#039; ||   || 	fraction of the vertical axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;point2=0.5&#039;&#039;&#039; ||   || 	fraction of the horizontal axis for front face&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || 	if y, draw scalebar&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
for sfgrey and sfgrey3. Examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfgrey==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Generate raster plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfgrey &amp;lt; in.rsf &amp;gt; out.rsf bar=bar.rsf transp=y yreverse=y xreverse=n gpow= phalf= clip= pclip= gainstep=0.5+n1/256. allpos=n bias=0. polarity=n verb=n scalebar=n minval= maxval= barreverse=n wantframenum=(bool) (n3 &amp;gt; 1) nreserve=8 gainpanel= bar= color= &amp;gt; (plot.vpl | char.rsf)&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Can input char values.&amp;lt;br&amp;gt;If called &amp;quot;byte&amp;quot;, outputs char values.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;allpos=n&#039;&#039;&#039; ||  [y/n] || 	if y, assume positive data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;bar=&#039;&#039;&#039; ||   || 	file for scalebar data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;barreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, go from small to large on the bar scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;color=&#039;&#039;&#039; ||   || 	color scheme (default is i)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;gainpanel=&#039;&#039;&#039; ||   || 	gain reference: &#039;a&#039; for all, &#039;e&#039; for each, or number&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+n1/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxval=&#039;&#039;&#039; ||   || 	maximum value for scalebar (default is the data maximum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;minval=&#039;&#039;&#039; ||   || 	minimum value for scalebar (default is the data minimum)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nreserve=8&#039;&#039;&#039; ||   || 	reserved colors&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=&#039;&#039;&#039; ||   || 	data clip percentile (default is 99)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;phalf=&#039;&#039;&#039; ||   || 	percentage for estimating gpow&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;polarity=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse polarity (white is high by default)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;scalebar=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=y&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the display axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;wantframenum=(bool) (n3 &amp;gt; 1)&#039;&#039;&#039; ||  [y/n] || 	if y, display third axis position in the corner&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=y&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Different [http://reproducibility.org/rsflog/index.php?/archives/14-Color-schemes.html color schemes] are available&lt;br /&gt;
and examples are in the book at [http://reproducibility.org/RSF/book/rsf/rsf/sfgrey.html rsf/rsf/sfgrey].&lt;br /&gt;
&lt;br /&gt;
==sfplas==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Assembler - convert ascii to vplot. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplas&lt;br /&gt;
|}&lt;br /&gt;
==sfpldb==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot Debugger - convert vplot to ascii. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpldb&lt;br /&gt;
|}&lt;br /&gt;
==sfplotrays==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot rays.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfplotrays frame=frame.rsf nt=n1*n2 jr=1 frame= &amp;lt; rays.rsf &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;frame=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jr=1&#039;&#039;&#039; ||   || 	skip rays&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nt=n1*n2&#039;&#039;&#039; ||   || 	maximum ray length&lt;br /&gt;
|}&lt;br /&gt;
==sfthplot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Hidden-line surface plot.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfthplot &amp;lt; in.rsf uflag=y dflag=y alpha=45. titlsz=9 axissz=6 plotfat=0 titlefat=2 axisfat=2 plotcolup=VP_YELLOW plotcoldn=VP_RED axis=y axis1=y axis2=y axis3=y clip=0. pclip=100. gainstep=0.5+nx/256. bias=0. dclip=1. norm=y xc=1.5 zc=3 ratio=5. zmax= zmin= sz=6. label#= unit#= tpow=0 epow=0 gpow=1 title= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;alpha=45.&#039;&#039;&#039; ||   || 	apparent angle in degrees, |alpha| &amp;lt; 89&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis1=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis2=y&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;axis3=y&#039;&#039;&#039; ||  [y/n] || 	plot axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axisfat=2&#039;&#039;&#039; ||   || 	axes fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;axissz=6&#039;&#039;&#039; ||   || 	axes size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;bias=0.&#039;&#039;&#039; ||   || 	subtract bias from data&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dclip=1.&#039;&#039;&#039; ||   || 	change the clip: clip *= dclip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;dflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot down side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;epow=0&#039;&#039;&#039; ||   || 	exponential gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gainstep=0.5+nx/256.&#039;&#039;&#039; ||   || 	subsampling for gpow and clip estimation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;gpow=1&#039;&#039;&#039; ||   || 	power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label#=&#039;&#039;&#039; ||   || 	label on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;norm=y&#039;&#039;&#039; ||  [y/n] || 	normalize by the clip&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=100.&#039;&#039;&#039; ||   || 	data clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcoldn=VP_RED&#039;&#039;&#039; ||   || 	color of the lower side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotcolup=VP_YELLOW&#039;&#039;&#039; ||   || 	color of the upper side&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;plotfat=0&#039;&#039;&#039; ||   || 	line fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ratio=5.&#039;&#039;&#039; ||   || 	plot adjustment&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;sz=6.&#039;&#039;&#039; ||   || 	vertical scale&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;title=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlefat=2&#039;&#039;&#039; ||   || 	title fatness&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;titlsz=9&#039;&#039;&#039; ||   || 	title size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;tpow=0&#039;&#039;&#039; ||   || 	time power gain&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;uflag=y&#039;&#039;&#039; ||  [y/n] || 	if y, plot upper side of the surface&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit#=&#039;&#039;&#039; ||   || 	unit on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xc=1.5&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zc=3&#039;&#039;&#039; ||   || 	lower left corner of the plot&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmax=&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zmin=&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
==sfwiggle==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Plot data with wiggly traces. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfwiggle &amp;lt; in.rsf xpos=xpos.rsf xmax= xmin= poly=n fatp=1 xmask=1 ymask=1 pclip=98. zplot=0.75 clip=0. seemean=n verb=n transp=n yreverse=n xreverse=n xpos= &amp;gt; plot.vpl&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Run &amp;quot;sfdoc stdplot&amp;quot; for more parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;clip=0.&#039;&#039;&#039; ||   || 	data clip (estimated from pclip by default&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;fatp=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;pclip=98.&#039;&#039;&#039; ||   || 	clip percentile&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;poly=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;seemean=n&#039;&#039;&#039; ||  [y/n] || 	if y, plot mean lines of traces&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;transp=n&#039;&#039;&#039; ||  [y/n] || 	if y, transpose the axes&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;xmask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmax=&#039;&#039;&#039; ||   || 	maximum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;xmin=&#039;&#039;&#039; ||   || 	minimum trace position (if using xpos)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;xpos=&#039;&#039;&#039; ||   || 	optional header file with trace positions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;xreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the horizontal axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ymask=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;yreverse=n&#039;&#039;&#039; ||  [y/n] || 	if y, reverse the vertical axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;zplot=0.75&#039;&#039;&#039; ||   || &lt;br /&gt;
|}&lt;br /&gt;
=Plotting programs (development)=&lt;br /&gt;
==sfplsurf==&lt;br /&gt;
&amp;lt;tt&amp;gt;sfplsurf&amp;lt;/tt&amp;gt; utilizes PLplot&#039;s surface rendering capabilities. Output is dumped to stdout in VPLOT format, so it can easily be used in the same way as &amp;lt;tt&amp;gt;sfgrey&amp;lt;/tt&amp;gt; or other plotting programs. It also supports animation, if n3 &amp;gt; 1 in the input file. A SConstruct usage example can be found below. A [http://reproducibility.org/wikilocal/movies/sfplsurf_membrane.mpg movie of the output] is available as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# x &amp;amp; y dimensions&lt;br /&gt;
o1=-2&lt;br /&gt;
o2=-2&lt;br /&gt;
n1=41&lt;br /&gt;
n2=41&lt;br /&gt;
d1=0.1&lt;br /&gt;
d2=0.1&lt;br /&gt;
# z dimension&lt;br /&gt;
o3=-1&lt;br /&gt;
n3=21&lt;br /&gt;
d3=0.1&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;membrane&#039;,None,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    math o1=%g o2=%g n1=%d n2=%d d1=%g d2=%g&lt;br /&gt;
          o3=%g n3=%d d3=%g&lt;br /&gt;
          output=&amp;quot;x3*cos(x1*x1+x2*x2)*exp(-0.1*(x1*x1+x2*x2))&amp;quot;&lt;br /&gt;
    &#039;&#039;&#039; % (o1,o2,n1,n2,d1,d2,o3,n3,d3))&lt;br /&gt;
&lt;br /&gt;
Result(&#039;membrane&#039;,&lt;br /&gt;
      &#039;&#039;&#039;&lt;br /&gt;
      plsurf title=&amp;quot;Membrane&amp;quot; mesh=n color=j&lt;br /&gt;
              minval=%g maxval=%g&lt;br /&gt;
      &#039;&#039;&#039; % (o3,o3 + d3*(n3-1)))&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=system/generic programs=&lt;br /&gt;
==sfremap1==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 1-D ENO interpolation. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfremap1 &amp;lt; in.rsf &amp;gt; out.rsf pattern=pattern.rsf n1=n1 d1=d1 o1=o1 order=3&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=d1&#039;&#039;&#039; ||   || 	Output sampling&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;n1=n1&#039;&#039;&#039; ||   || 	Number of output samples&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=o1&#039;&#039;&#039; ||   || 	Output origin&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;order=3&#039;&#039;&#039; ||   || 	Interpolation order&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;pattern=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|}&lt;br /&gt;
To give an example of usage, we will create an input for &amp;lt;tt&amp;gt;sfremap1&amp;lt;/tt&amp;gt; with:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=11 n2=11 d1=1 d2=1 o1=-5 o2=-5 output=&amp;quot;x1*x1+x2*x2&amp;quot; &amp;gt; inp2remap1.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Let us interpolate the data across both dimensions, then display it:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt; inp2remap1.rsf sfremap1 n1=1001 d1=0.01 | sftransp | \&lt;br /&gt;
sfremap1 n1=1001 d1=0.01 | sftransp | sfgrey allpos=y | sfpen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The comparison with the uninterpolated data ( &amp;lt;tt&amp;gt;&amp;amp;lt; inp2remap1.rsf sfgrey allpos=y | sfpen&amp;lt;/tt&amp;gt; ) is quite telling.&lt;br /&gt;
&lt;br /&gt;
=system/seismic programs=&lt;br /&gt;
==sfstretch==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Stretch of the time axis. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfstretch &amp;lt; in.rsf &amp;gt; out.rsf datum=dat.rsf inv=n dens=1 v0= half=y delay= tdelay= hdelay= nout=dens*n1 extend=4 mute=0 maxstr=0 rule=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;datum=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;delay=&#039;&#039;&#039; ||   || 	time delay for rule=lmo&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;dens=1&#039;&#039;&#039; ||   || 	axis stretching factor&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;extend=4&#039;&#039;&#039; ||   || 	trace extension&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;half=y&#039;&#039;&#039; ||  [y/n] || 	if y, the second axis is half-offset instead of full offset&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;hdelay=&#039;&#039;&#039; ||   || 	offset delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;inv=n&#039;&#039;&#039; ||  [y/n] || 	if y, do inverse stretching&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;maxstr=0&#039;&#039;&#039; ||   || 	maximum stretch&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;mute=0&#039;&#039;&#039; ||   || 	tapering size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nout=dens*n1&#039;&#039;&#039; ||   || 	output axis length (if inv=n)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;rule=&#039;&#039;&#039; ||   || 	Stretch rule:&lt;br /&gt;
:n - normal moveout (nmostretch), default&lt;br /&gt;
:l - linear moveout (lmostretch)&lt;br /&gt;
:L - logarithmic stretch (logstretch)&lt;br /&gt;
:2 - t^2 stretch (t2stretch)&lt;br /&gt;
:c - t^2 chebyshev stretch (t2chebstretch)&lt;br /&gt;
:r - radial moveout (radstretch)&lt;br /&gt;
:d - datuming (datstretch)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;tdelay=&#039;&#039;&#039; ||   || 	time delay for rule=rad&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;v0=&#039;&#039;&#039; ||   || 	moveout velocity&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sfstretch rule=d&amp;lt;/tt&amp;gt; (aka &amp;lt;tt&amp;gt;sfdatstretch&amp;lt;/tt&amp;gt;) can be used to apply statics. Here is a synthetic example, courtesy of Alessandro Frigeri:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# generate a dataset with &#039;flat&#039; signals&lt;br /&gt;
sfmath n1=200 n2=100 output=&amp;quot;sin(0.5*x1)&amp;quot; type=float &amp;gt; scan.rsf&lt;br /&gt;
&lt;br /&gt;
# generate a sinusoidal elevation correction&lt;br /&gt;
sfmath n1=100 output=&amp;quot;3*sin(x1)&amp;quot; type=float &amp;gt; statics.rsf&lt;br /&gt;
&lt;br /&gt;
# apply statics, producing a &#039;wavy&#039; output.&lt;br /&gt;
sfstretch &amp;lt; scan.rsf &amp;gt; out.rsf datum=statics.rsf rule=d&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/fomels programs=&lt;br /&gt;
==sfpick==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Automatic picking  from semblance-like panels. &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfpick &amp;lt; scn.rsf &amp;gt; pik.rsf vel0=o2 niter=100 an=1. gate=3 smooth=y rect#=(1,1,...) rect1=1 rect2=1 ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | rectN defines the size of the smoothing stencil in N-th dimension.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Theory in Appendix B of:&amp;lt;br&amp;gt;S. Fomel, 2009, &amp;lt;br&amp;gt;Velocity analysis using AB semblance: Geophysical Prospecting, v. 57, 311-321.&amp;lt;br&amp;gt;Reproducible version in RSFSRC/book/jsg/avo &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;an=1.&#039;&#039;&#039; ||   || 	axes anisotropy&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;gate=3&#039;&#039;&#039; ||   || 	picking gate&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;niter=100&#039;&#039;&#039; ||   || 	number of iterations&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;rect#=(1,1,...)&#039;&#039;&#039; ||   || 	smoothing radius on #-th axis&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;smooth=y&#039;&#039;&#039; ||  [y/n] || 	if apply smoothing&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vel0=o2&#039;&#039;&#039; ||   || 	surface velocity&lt;br /&gt;
|}&lt;br /&gt;
Short description of the algorithm:&lt;br /&gt;
# Start from the top (first time slice), pick an initial (source) point, evaluate all other points with the direct traveltime.&lt;br /&gt;
# At each grid point at the next level, find the traveltime to points at the previous level, add the traveltimes from the previous level, and select minimum. The search radius is limited by the aperture (gate= parameter in sfpick).&lt;br /&gt;
# Repeat step 2 until reaching the bottom.&lt;br /&gt;
# Pick the minimum traveltime at the bottom and track the ray back to the source by following the traveltime gradient direction.&lt;br /&gt;
# Postprocessing (smooth= parameter in sfpick): smooth the picked ray path using shaping regularization.&lt;br /&gt;
&lt;br /&gt;
The algorithm was discovered and rediscovered by many people. The best reference is probably &#039;&#039;V. Meshbey, E. Ragoza, D. Kosloff, U. Egozi, and D. Wexler, 2002, Three-dimensional Travel-time Calculation Based on Fermat&#039;s Principle: Pure and Applied Geophysics, v. 159, 1563-1582.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=user/ivlad programs=&lt;br /&gt;
==sfprep4plot==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Resamples a 2-D dataset to the desired picture resolution, with antialias&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfprep4plot inp= out= verb=n h=none w=none unit= ppi= prar=y&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Only one of the h and w parameters needs to be specified.&amp;lt;br&amp;gt;If prar=n, no action will be taken on axis for which h/w was not specified&amp;lt;br&amp;gt;If prar=y and only one par (h or w) is specified, the picture will scale&amp;lt;br&amp;gt;along both axes until it is of the specified dimension.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;h=none&#039;&#039;&#039; ||   || 	output height&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;inp=&#039;&#039;&#039; ||   || 	input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;out=&#039;&#039;&#039; ||   || 	output file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ppi=&#039;&#039;&#039; ||   || 	output resolution (px/in). Necessary when unit!=px&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;prar=y&#039;&#039;&#039; ||  [y/n] || 	if y, PReserve Aspect Ratio of input&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit=&#039;&#039;&#039; ||   || 	unit of h and w. Can be: px(default), mm, cm, in&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	if y, print system commands, outputs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;w=none&#039;&#039;&#039; ||   || 	output width&lt;br /&gt;
|}&lt;br /&gt;
For a figure that does not need the aspect ratio preserved,&lt;br /&gt;
and needs to fill a 1280x1024 projector display:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=1280 h=1024 prar=n&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a print figure that has to fit in a 6x8in box&lt;br /&gt;
at a resolution of 250 dpi, preserving the aspect ratio:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfprep4plot inp=file1.rsf out=file2.rsf w=6 h=8 unit=in ppi=250&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A comparison of images before and after the application of &amp;lt;tt&amp;gt;sfprep4plot&amp;lt;/tt&amp;gt;, courtesy of Joachim Mispel, is shown below:&lt;br /&gt;
&lt;br /&gt;
[[Image:sf_prep4plot.jpg]]&lt;br /&gt;
&lt;br /&gt;
==sfcsv2rsf==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Convert a delimited-text ASCII file to RSF binary floating point or int.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfcsv2rsf help=n delimiter=, dtype=float verb=n debug=n trunc=n o1=0. o2=0. d1=1. d2=1. unit1=unknown unit2=unknown label1=unknown label2=unknown&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Zeros will be added if number of elements is not the same in each row.&amp;lt;br&amp;gt;n1 and n2 are computed automatically. For consistency with sfdisfil and &amp;lt;br&amp;gt;sfmatmult, output is C-style order (row-first), i.e. rows in input file &amp;lt;br&amp;gt;become dimension-1 columns in output. Output encoding is native.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d1=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;d2=1.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;debug=n&#039;&#039;&#039; ||  [y/n] || 	Extra verbosity for debugging&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;delimiter=,&#039;&#039;&#039; ||   || 	Separator between values in input file&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;dtype=float&#039;&#039;&#039; ||   || 	Input type&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;help=n&#039;&#039;&#039; ||  [y/n] || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;label2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o1=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;o2=0.&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;trunc=n&#039;&#039;&#039; ||  [y/n] || 	Truncate or add zeros if nr elems in rows differs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit1=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;unit2=unknown&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	Whether to echo n1, n2, infill/truncation&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A small usage example follow below. First, create an input file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ echo -e &#039;5,6,8,9.2\n11,124,5,0,1&#039; | tee file.csv&lt;br /&gt;
5,6,8,9.2&lt;br /&gt;
11,124,5,0,1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may notice that the number of values in each row is different.&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;tt&amp;gt;sfcsv2rsf&amp;lt;/tt&amp;gt;. Notice that no options are needed. By default, zeros will be appended to make the rows equal length:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf &amp;gt; junk.rsf ; sfdisfil &amp;lt; junk.rsf &lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that sfdisfil displays in column order (i.e. matrix is transposed if the number of rows is right). The dimensions of the file are actually transposed on disk:&lt;br /&gt;
&lt;br /&gt;
$ sfin junk.rsf&lt;br /&gt;
junk.rsf:&lt;br /&gt;
    in=&amp;quot;/data/path/junk.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native &lt;br /&gt;
    n1=5           d1=1           o1=0          unit1=&amp;quot;unknown&amp;quot; &lt;br /&gt;
    n2=2           d2=1           o2=0          unit2=&amp;quot;unknown&amp;quot; &lt;br /&gt;
	10 elements 40 bytes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may want to run the output through &amp;lt;tt&amp;gt;sftransp&amp;lt;/tt&amp;gt;, depending on your needs. However, if creating an input for &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt;, this will not be necessary, because &amp;lt;tt&amp;gt;sfmatmult&amp;lt;/tt&amp;gt; is made to work with matrices that are displayed with &amp;lt;tt&amp;gt;sfdisfil&amp;lt;/tt&amp;gt;, and takes as input a transpose matrix.&lt;br /&gt;
&lt;br /&gt;
Pipes can be used, of course, to skip the creation of intermediary files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
$ &amp;lt;file.csv sfcsv2rsf | sfdisfil&lt;br /&gt;
   0:             5            6            8          9.2            0&lt;br /&gt;
   5:            11          124            5            0            1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that since this program does not need any arguments (just stdin and stdout), when called with no arguments it will not display the man page. In order to consult the automatically generated documentation, you need to pass the option &amp;lt;tt&amp;gt;help=y&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
=user/jennings programs=&lt;br /&gt;
==sfsizes==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Display the size of RSF files.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsizes files=y human=n file1.rsf file2.rsf ...&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; | Prints the element size, number of elements, and number of bytes&amp;lt;br&amp;gt;for a list of RSF files.  Non-RSF files are ignored.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;files=y&#039;&#039;&#039; ||  [y/n] || 	If y, print size of each file.  If n, print only total.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;human=n&#039;&#039;&#039; ||  [y/n] || 	If y, print human-readable file size.  If n, print byte count.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This program computes the &amp;quot;theoretical&amp;quot; size in bytes of the data fork of RSF files.  The actual space occupied on disk may be different and machine dependent due to disk blocking factors, etc.  This theoretical array size should be reproducible.  It is also fast because the program only reads the RSF headers files, not the actual data.&lt;br /&gt;
&lt;br /&gt;
For example, to get the total size of all RSF files in a directory, in human readable format, without listing each file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will also work because sfsizes simply skips any non-RSF file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfsizes files=n human=y *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==sffiglist==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | Compare Vplot files in Fig and Lock directories&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sffiglist figdir= lockdir= list= show=&lt;br /&gt;
|-&lt;br /&gt;
|  colspan=&amp;quot;4&amp;quot; |&lt;br /&gt;
Parameter &#039;&#039;&#039;figdir&#039;&#039;&#039; is path to Fig directory, default is ./Fig.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;lockdir&#039;&#039;&#039; is path to Lock directory:&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&amp;lt;br&amp;gt;    If &#039;&#039;&#039;figdir&#039;&#039;&#039; is not in $RSFSRC/book/[book]/[chapter]/[section],&lt;br /&gt;
&amp;lt;br&amp;gt;        then default &#039;&#039;&#039;lockdir&#039;&#039;&#039; is $RSFALTFIGS/[book]/[chapter]/[section].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;list&#039;&#039;&#039; controls files to list, default is all.&lt;br /&gt;
&amp;lt;br&amp;gt;Parameter &#039;&#039;&#039;show&#039;&#039;&#039; controls files to flip with sfpen, default is none.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = none (No files, print only summary.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = diff (Files that are different, determined by sfvplotdiff.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = miss (Files missing from figdir or lockdir, and different files.)&lt;br /&gt;
&amp;lt;br&amp;gt;&#039;&#039;&#039;list|show&#039;&#039;&#039; = all (All files.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;File list codes:&lt;br /&gt;
&amp;lt;br&amp;gt;space   indicates files that are the same.&lt;br /&gt;
&amp;lt;br&amp;gt;  -     indicates file in lockdir that is missing from figdir.&lt;br /&gt;
&amp;lt;br&amp;gt;  +     indicates extra file in figdir that is missing from lockdir.&lt;br /&gt;
&amp;lt;br&amp;gt;number  is return code from sfvplotdiff indicating different files.&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;figdir=&#039;&#039;&#039; ||   || 	fig directory, default = ./Fig&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;list=&#039;&#039;&#039; ||   || 	how much to list [none,diff,miss,all], default = all&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;lockdir=&#039;&#039;&#039; ||   || 	lock directory, default = lock counterpart of figdir&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;show=&#039;&#039;&#039; ||   || 	how much to show [none,diff,miss,all], default = none&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tool lists Vplot files in &amp;quot;Fig&amp;quot; and &amp;quot;Lock&amp;quot; directories and compares them using sfvplotdiff.&lt;br /&gt;
&lt;br /&gt;
The Fig directory defaults to ./Fig and the Lock directory defaults to the  &lt;br /&gt;
corresponding directory where &amp;quot;scons lock&amp;quot; puts things, but either  &lt;br /&gt;
default can be overridden with the user parameters &#039;&#039;&#039;figdir&#039;&#039;&#039; and &#039;&#039;&#039;lockdir&#039;&#039;&#039; so that, for example,  &lt;br /&gt;
files in two different Fig directories can be compared.&lt;br /&gt;
&lt;br /&gt;
The default for the Lock directory has some logic to look in $RSFFIGS  &lt;br /&gt;
when Fig is in $RSFSRC/book, or to look in $RSFALTFIGS when Fig is not  &lt;br /&gt;
in $RSFSRC/book because I like to keep two different Lock directories:  &lt;br /&gt;
one for stuff in book and another for my own stuff that is not in  &lt;br /&gt;
book.  However, I tried to make the code default to reasonable things  &lt;br /&gt;
if any of these environment variables are not defined.&lt;br /&gt;
&lt;br /&gt;
The tool gives a summary count of files that are the same, files that  &lt;br /&gt;
are different, files in Fig that are missing from Lock, and files in  &lt;br /&gt;
Lock that are missing from Fig.&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;list&#039;&#039;&#039; (default=all) and &#039;&#039;&#039;show&#039;&#039;&#039; (default=none) control which files are listed or &amp;quot;flipped&amp;quot; with sfpen.  The file listing indicates which files are the same, which are different, and which are missing from Fig or Lock.&lt;br /&gt;
&lt;br /&gt;
For example, to list all the Vplot files in Fig and Lock:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To list all Vplot files and flip only files that are different:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sffiglist list=all show=diff&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=user/psava programs=&lt;br /&gt;
&lt;br /&gt;
==sfawefd==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | acoustic time-domain FD modeling &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfawefd &amp;lt; Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf &amp;gt; Fdat.rsf den=Fden.rsf ompchunk=1 ompnth=0 verb=n snap=n free=n expl=n jdata=1 jsnap=nt nq1=sf_n(a1) nq2=sf_n(a2) oq1=sf_o(a1) oq2=sf_o(a2)&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;den=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;expl=n&#039;&#039;&#039; ||  [y/n] || 	&amp;quot;exploding reflector&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;free=n&#039;&#039;&#039; ||  [y/n] || 	free surface flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jdata=1&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;jsnap=nt&#039;&#039;&#039; ||   || 	save wavefield every *jsnap* time steps&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq1=sf_n(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nq2=sf_n(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   || 	OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   || 	OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq1=sf_o(a1)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oq2=sf_o(a2)&#039;&#039;&#039; ||   || &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rec=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;snap=n&#039;&#039;&#039; ||  [y/n] || 	wavefield snapshots flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;sou=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;vel=&#039;&#039;&#039; ||   || 	auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=n&#039;&#039;&#039; ||  [y/n] || 	verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;wfl=&#039;&#039;&#039; ||   || 	auxiliary output file name&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
An example will be demonstrated below on a model with nx=nz=200, dx=dz=4m (size: 800x800m). There are two layers: the first one is 100x200 samples in (z,x) and the velocity is 1500m/s; the second layer has the same dimension and the velocity is 3000m/s. Density is set to 1 for the whole grid. A source and a receiver are co-located at x=400 and z=100. The full wavefield for the entire model aperture will be saved every 10th time step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
# Velocity model:&lt;br /&gt;
sfspike &amp;gt;Fvel.rsf mag=1500,3000 nsp=2 k1=1,101 l1=100,200 d1=4 d2=4 \&lt;br /&gt;
label1=z label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Density model:&lt;br /&gt;
sfspike &amp;gt;Fden.rsf mag=1 nsp=1 k1=1 l1=200 d1=4 d2=4 label1=z \&lt;br /&gt;
label2=x n1=200 n2=200 o1=2 o2=2 unit1=m unit2=m&lt;br /&gt;
&lt;br /&gt;
# Source position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Fsou.rsf&lt;br /&gt;
&lt;br /&gt;
# Receiver position (x,z):&lt;br /&gt;
sfspike n1=2 nsp=2 k1=1,2 mag=400,100 o1=0 o2=0 &amp;gt;Frec.rsf&lt;br /&gt;
&lt;br /&gt;
# Source wavelet:&lt;br /&gt;
sfspike nsp=1 n1=2000 d1=0.0005 k1=200 | sfricker1 frequency=20 |\&lt;br /&gt;
sftransp &amp;gt;Fwav.rsf&lt;br /&gt;
&lt;br /&gt;
# Creating data at specified receiver + saving full wavefield every 10th step:&lt;br /&gt;
sfawefd2d &amp;lt;Fwav.rsf vel=Fvel.rsf sou=Fsou.rsf rec=Frec.rsf wfl=Fwfl.rsf \&lt;br /&gt;
den=Fden.rsf &amp;gt;Fdat.rsf verb=y free=y expl=y snap=y dabc=y jdata=1 jsnap=10&lt;br /&gt;
echo &#039;label1=z unit1=m label2=x unit2=m&#039; &amp;gt;&amp;gt; Fwfl.rsf&lt;br /&gt;
&lt;br /&gt;
# View the wavefield movie:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfgrey gainpanel=a pclip=99 color=j scalebar=y | sfpen &lt;br /&gt;
&lt;br /&gt;
# View a wavefield snapshot:&lt;br /&gt;
&amp;lt; Fwfl.rsf sfwindow f3=80 n3=1 |\&lt;br /&gt;
sfgrey pclip=99 color=j title=&#039;snapshot at t=0.4s&#039; |\&lt;br /&gt;
sfpen &lt;br /&gt;
&lt;br /&gt;
# View the data recorded at receiver:&lt;br /&gt;
&amp;lt;Fdat.rsf sfwindow |\&lt;br /&gt;
sfgraph title=&#039;Data recorded at receiver&#039; unit2=&#039;&#039; label2=amplitude |\&lt;br /&gt;
sfpen&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:sfawefd_wfld.jpg|frame|center|sfawefd wavefield screenshot]]&lt;br /&gt;
[[Image:sfawefd_dat.png|frame|center|sfawefd data screenshot]]&lt;br /&gt;
&lt;br /&gt;
Attention: time steps that are too large can result in numerical instability.&lt;br /&gt;
&lt;br /&gt;
==sfsrmig3==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot; | 3-D S/R migration with extended SSF&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;4&amp;quot; | sfsrmig3 slo=Fs_s.rsf sls=Fs_r.rsf &amp;lt; Fw_s.rsf rwf=Fw_r.rsf &amp;gt; Fi.rsf cig=Fc.rsf ompchunk=1 ompnth=0 verb=y eps=0.01 twoway=n nrmax=1 dtmax=0.004 pmx=0 pmy=0 tmx=0 tmy=0 vpvs=1. hsym=n nht=1 oht=0 dht=0.1 nht=1 oht=0 dht=0.1 hsym=n nhh=1 ohh=0 dhh=0.1 nha=180 oha=0 dha=2.0 nhb=180 ohb=0 dhb=2.0 itype=&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;cig=&#039;&#039;&#039; ||   ||     auxiliary output file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dha=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhb=2.0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dhh=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dht=0.1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;dtmax=0.004&#039;&#039;&#039; ||   ||      max time error&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;eps=0.01&#039;&#039;&#039; ||   ||         stability parameter&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;hsym=n&#039;&#039;&#039; ||  [y/n] ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;itype=&#039;&#039;&#039; ||   ||   imaging condition type&lt;br /&gt;
:o = zero lag (default)&lt;br /&gt;
:e = extended&lt;br /&gt;
:x = space-lags&lt;br /&gt;
:h = space-lags magnitude&lt;br /&gt;
:t = time-lag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nha=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhb=180&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nhh=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nht=1&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;nrmax=1&#039;&#039;&#039; ||   ||  max number of refs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oha=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohb=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;ohh=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;oht=0&#039;&#039;&#039; ||   ||&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompchunk=1&#039;&#039;&#039; ||   ||       OpenMP data chunk size&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;ompnth=0&#039;&#039;&#039; ||   ||         OpenMP available threads&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmx=0&#039;&#039;&#039; ||   ||    padding on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;pmy=0&#039;&#039;&#039; ||   ||    padding on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;rwf=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;file   &#039;&#039; || &#039;&#039;&#039;slo=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;string &#039;&#039; || &#039;&#039;&#039;sls=&#039;&#039;&#039; ||   ||     auxiliary input file name&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmx=0&#039;&#039;&#039; ||   ||    taper on x&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;int    &#039;&#039; || &#039;&#039;&#039;tmy=0&#039;&#039;&#039; ||   ||    taper on y&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;twoway=n&#039;&#039;&#039; ||  [y/n] ||    two-way traveltime&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;bool   &#039;&#039; || &#039;&#039;&#039;verb=y&#039;&#039;&#039; ||  [y/n] ||      verbosity flag&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;float  &#039;&#039; || &#039;&#039;&#039;vpvs=1.&#039;&#039;&#039; ||   ||  Vp/Vs ratio&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This program performs 3-D and 2-D shot-record (a.k.a. shot-profile) migration with an extended Split-Step Fourier (SSF) extrapolator with multiple reference velocities (hence &amp;quot;extended&amp;quot;). It takes as input a shot wavefield (&amp;lt;tt&amp;gt;stdin&amp;lt;/tt&amp;gt;), receiver wavefield (&amp;lt;tt&amp;gt;rwf=&amp;lt;/tt&amp;gt;) and slowness model (&amp;lt;tt&amp;gt;slo=&amp;lt;/tt&amp;gt;). Outputs are an image (&amp;lt;tt&amp;gt;stdout&amp;lt;/tt&amp;gt;) and a cube of Common Image Gathers (&amp;lt;tt&amp;gt;cig=&amp;lt;/tt&amp;gt;). An important parameter is &amp;lt;tt&amp;gt;nrmax&amp;lt;/tt&amp;gt;, the number of reference velocities. Its default value is 1, but for reasonable results it should be 5 or so. It is also good to specify nonzero taper values (&amp;lt;tt&amp;gt;tmx&amp;lt;/tt&amp;gt; and, for 3-D, &amp;lt;tt&amp;gt;tmy&amp;lt;/tt&amp;gt; as well). The values of padding parameters &amp;lt;tt&amp;gt;pmx&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;pmy&amp;lt;/tt&amp;gt; are split in two by the program, i.e. if your data x axis is 501-points long, specify pmx=11 to get a value of 512 that will result in fast Fourier Transforms. &lt;br /&gt;
&lt;br /&gt;
The program will also migrate converted-wave data if a file with the S-wave slowness model (&amp;lt;tt&amp;gt;sls=&amp;lt;/tt&amp;gt;) is provided.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; parameter is only used when &amp;lt;tt&amp;gt;itype=h&amp;lt;/tt&amp;gt;. Do not specify a &amp;lt;tt&amp;gt;vpvs&amp;lt;/tt&amp;gt; value unless you know really well what you are doing.&lt;br /&gt;
&lt;br /&gt;
===Usage example===&lt;br /&gt;
The commands below, slightly modified from [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/data/sigsbee/ptest/SConstruct?revision=3993&amp;amp;view=markup RSFSRC/book/data/sigsbee/ptest], show how to prepare the [http://www.reproducibility.org/RSF/book/data/sigsbee Sigsbee 2A] data and velocity for migration.&lt;br /&gt;
&lt;br /&gt;
Convert input data (shots) from SEG-Y to RSF:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_nfs.segy tfile=tdata.rsf hfile=/dev/null bfile=/dev/null &amp;gt; ddata.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Convert trace headers to float (required by &amp;lt;tt&amp;gt;sfheadermath&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; tdata.rsf sfdd type=float &amp;gt; trchdr.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Shot positions:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;fldr + 10925/150&amp;quot; | sfwindow squeeze=y &amp;gt; tsi.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Extract offset positions from the trace header files, eliminate length-1 axis, scale, create a header for binning (required by &amp;lt;tt&amp;gt;sfintbin&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; trchdr.rsf sfheadermath output=&amp;quot;offset&amp;quot; |\&lt;br /&gt;
sfwindow squeeze=y |\&lt;br /&gt;
sfmath output=&amp;quot;input/75&amp;quot; |\&lt;br /&gt;
sfcat axis=2 space=n tsi.rsf |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfdd type=int &amp;gt; tos.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Binning and muting:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; ddata.rsf sfintbin head=tos.rsf xkey=0 ykey=1 |\&lt;br /&gt;
sfput label1=Time unit1=s d2=0.075 o2=0.0 label2=hx d3=0.150 o3=10.925 label3=sx |\&lt;br /&gt;
sfmutter half=false t0=1.0 v0=6.0 |\&lt;br /&gt;
sfput d2=0.02286 o2=0 unit2=km d3=0.04572 o3=3.32994 unit3=km &amp;gt; shots.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Keeping only 20 shots so that this 1-node job will not take forever, FFT-ing, decimating frequency slices (same as shortening the time axis), and creating y and hy axes of length 1:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; shots.rsf sfwindow n3=20 f3=10 j3=20 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfspray axis=3 n=1 o=0 d=1 label=hy |\&lt;br /&gt;
sfspray axis=5 n=1 o=0 d=1 label=sy &amp;gt; rfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The dimensions of the cube thus created are:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin rfft.rsf trail=n&lt;br /&gt;
rfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;Frequency&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n2=348         d2=0.02286     o2=0          label2=&amp;quot;hx&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=1           d3=1           o3=0          label3=&amp;quot;hy&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
    n4=20          d4=0.9144      o4=3.78714    label4=&amp;quot;sx&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        1392000 elements 11136000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create the source wavelet (limited to the same frequency band as the data) and Fourier transform it:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfspike k1=1 n1=1500 d1=0.008 |\&lt;br /&gt;
sfbandpass flo=15 fhi=25 |\&lt;br /&gt;
sffft1 |\&lt;br /&gt;
sfwindow n1=200 min1=1 j1=3 |\&lt;br /&gt;
sfput label1=freq &amp;gt; sfft.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a frequency-domain wavelet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin sfft.rsf&lt;br /&gt;
sfft.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/sfft.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=200         d1=0.25        o1=1          label1=&amp;quot;freq&amp;quot; unit1=&amp;quot;Hz&amp;quot;&lt;br /&gt;
        200 elements 1600 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Create &amp;quot;synched&amp;quot; source and receiver wavefields with &amp;lt;tt&amp;gt;srsyn&amp;lt;/tt&amp;gt; from wavelet and data frequency slices. Basically both the receiver and shot frequency slices are &amp;quot;placed&amp;quot; at the right location and padded with zeros up to the dimension of the x axis specified below.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rfft.rsf sfsrsyn nx=1067 dx=0.02286 ox=3.05562 wav=sfft.rsf swf=swav.rsf &amp;gt; rwav.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates frequency slices ready for migration for both source and receiver, only axis 1 (frequency) must become axis 3, for both datasets:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; swav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; stra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; rwav.rsf sftransp plane=12 | sftransp plane=23 &amp;gt; rtra.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a surface receiver wavefield ready for input to migration. Axis 4 is shot number. The values of axis 4 are arbitrary because each shot has been padded with zeros so that it covers the entire velocity model. Therefore the aperture of the downward continuation for each shot will be as large as the survey.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfin trail=n rtra.rsf&lt;br /&gt;
rtra.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/rtra.rsf@&amp;quot;&lt;br /&gt;
    esize=8 type=complex form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=200         d3=0.25        o3=1          label3=&amp;quot;w&amp;quot; unit3=&amp;quot;Hz&amp;quot;&lt;br /&gt;
    n4=20          d4=1           o4=0          label4=&amp;quot;e&amp;quot; unit4=&amp;quot;km&amp;quot;&lt;br /&gt;
        4268000 elements 34144000 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Convert the velocity model from SEG-Y to RSF, decimate, convert from feet to km, transpose, convert to slowness and insert an additional axis:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
sfsegyread tape=sigsbee2a_migvel.sgy tfile=/dev/null hfile=/dev/null bfile=/dev/null |\&lt;br /&gt;
sfput o1=0 d1=0.00762 label1=z unit1=km o2=3.05562 d2=0.01143 label2=x unit2=km |\&lt;br /&gt;
sfwindow j1=4 j2=2 |\&lt;br /&gt;
sfscale rscale=0.0003048 |\&lt;br /&gt;
sftransp |\&lt;br /&gt;
sfmath output=&amp;quot;1/input&amp;quot; |\&lt;br /&gt;
sfspray axis=2 n=1 d=1 o=0 |\&lt;br /&gt;
sfput label2=y &amp;gt; slow.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
This creates a slowness file ready for input to migration, with an x axis identical to the x axis of the wavefield files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin slow.rsf&lt;br /&gt;
slow.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/slow.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, the migration command (for a 4-processor machine, hence the &amp;lt;tt&amp;gt;ompnth&amp;lt;/tt&amp;gt; value). We choose not to compute any image gathers (&amp;lt;tt&amp;gt;itype=o&amp;lt;/tt&amp;gt;), but due to the construction of the program we still have to explicitly assign the &amp;lt;tt&amp;gt;cig&amp;lt;/tt&amp;gt; tag, or else a RSF file with the name of the tag and no rsf extension will be created:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt; stra.rsf sfsrmig3 nrmax=20 dtmax=5e-05 eps=0.01 verb=y ompnth=4 \&lt;br /&gt;
tmx=16 rwf=rtra.rsf slo=slow.rsf itype=o cig=/dev/null &amp;gt; img.rsf&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The migration of 20 shots takes approximately 3 hours on a 4-processor machine (1 shot=9 minutes). Without the frequency slice decimation by a factor of 3 and the depth axis decimation by a factor of 4, it would have taken twelve times as much. The resulting image has a y axis of length 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sfin img.rsf trail=n&lt;br /&gt;
img.rsf:&lt;br /&gt;
    in=&amp;quot;/var/tmp/img.rsf@&amp;quot;&lt;br /&gt;
    esize=4 type=float form=native&lt;br /&gt;
    n1=1067        d1=0.02286     o1=3.05562    label1=&amp;quot;x&amp;quot; unit1=&amp;quot;km&amp;quot;&lt;br /&gt;
    n2=1           d2=1           o2=0          label2=&amp;quot;y&amp;quot; unit2=&amp;quot;km&amp;quot;&lt;br /&gt;
    n3=301         d3=0.03048     o3=0          label3=&amp;quot;z&amp;quot; unit3=&amp;quot;km&amp;quot;&lt;br /&gt;
        321167 elements 1284668 bytes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To properly visualize the image, we need to eliminate the axis of length 1, then transpose the x and z axes to their natural position:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
&amp;lt;img.rsf sfwindow squeeze=y | sftransp | sfgrey &amp;gt; img.vpl&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=1973</id>
		<title>Guide to madagascar API</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=1973"/>
		<updated>2011-08-06T02:05:47Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Python interfaces to the Madagascar standalone programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_555071_XS.jpg|right|]]&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/api.tex?view=markup book/rsf/rsf/api.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide explains the RSF programming interface.  See the &#039;&#039;&#039;[[Library_Reference | Library Reference]]&#039;&#039;&#039; for more information on how to use the particular APIs.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To work with RSF files in your own programs, you may need to use an&lt;br /&gt;
appropriate programming interface. We will demonstrate the interface in&lt;br /&gt;
different languages using a simple example. The example is a clipping program.&lt;br /&gt;
It reads and writes RSF files and accesses parameters both from the input file&lt;br /&gt;
and the command line. The input is processed trace by trace. This is not&lt;br /&gt;
necessarily the most efficient approach&amp;lt;ref&amp;gt;Compare with the [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/filt/proc/Mclip.c?view=markup library clip program].&amp;lt;/ref&amp;gt; but it suffices for a simple demonstration.&lt;br /&gt;
&lt;br /&gt;
==Installation== &lt;br /&gt;
Only the C interface is installed by default. To install other APIs, use &amp;lt;tt&amp;gt;API=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameter in the RSF configuration. For example, to install C++ and&lt;br /&gt;
Fortran-90 API bindings in addition to the basic package, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure API=c++,fortran-90&lt;br /&gt;
scons install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The configuration parameters are stored in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C interface==&lt;br /&gt;
&lt;br /&gt;
The C clip function is listed below.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    int n1, n2, i1, i2;&lt;br /&gt;
    float clip, *trace=NULL;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    sf_close();&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The include preprocessing directive is required to access the RSF interface. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF data files are defined with an abstract &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; data type. An&lt;br /&gt;
abstract data type means that the contents of it are not publicly declared,&lt;br /&gt;
and all operations on &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; objects should be performed with&lt;br /&gt;
library functions. This is analogous to &amp;lt;tt&amp;gt;FILE *&amp;lt;/tt&amp;gt; data type used in&lt;br /&gt;
&amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; and as close as C gets to an object-oriented style of&lt;br /&gt;
programming (Roberts, 1998&amp;lt;ref&amp;gt;Roberts, E. S.,  1998, Programming abstractions in C: Addison-Wesley.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any of the other functions, you must call&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;. This function parses the command line and&lt;br /&gt;
initializes an internally stored table of command-line parameters.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output RSF file objects are created with &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt; constructor functions. Both these functions take a string&lt;br /&gt;
argument. The string may refer to a file name or a file tag. For example, if&lt;br /&gt;
the command line contains &amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the standard&lt;br /&gt;
output. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). We extract the data type of the input file&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; function and check if it&lt;br /&gt;
represents floating point numbers. If not, the program is aborted with&lt;br /&gt;
an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function. Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt; returns the total number of elements in&lt;br /&gt;
the hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product&lt;br /&gt;
of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we avoid the need&lt;br /&gt;
to extract additional parameters for the hypercube dimensions that we&lt;br /&gt;
are not interested in.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Next, we allocate an array of floating-point numbers to store a trace&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_floatalloc&amp;lt;/tt&amp;gt; function. Unlike the standard&lt;br /&gt;
&amp;lt;tt&amp;gt;malloc&amp;lt;/tt&amp;gt; the RSF allocation function checks for errors and&lt;br /&gt;
either terminates the program or returns a valid pointer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The rest of the program is straightforward. We loop over all available&lt;br /&gt;
traces, read each trace, clip it and right the output out. The syntax&lt;br /&gt;
of &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt; functions is&lt;br /&gt;
similar to the syntax of the C standard &amp;lt;tt&amp;gt;fread&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;fwrite&amp;lt;/tt&amp;gt; function except that the type of the element is&lt;br /&gt;
specified explicitly in the function name and that the input and&lt;br /&gt;
output files have the RSF type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
sf_close();&lt;br /&gt;
exit(0)&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We explicitly close the input file to avoid leaving a stale temporary file in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; if the program is called in a pipe sequence. Then, we close the program by sending the shell the Unix code that tells it no errors were encountered. &lt;br /&gt;
&lt;br /&gt;
Note that this is an introductory example, optimized for clarity, not execution speed. For advanced techniques, see [[Madagascar Code Patterns]].&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt; program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cc clip.c -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;cc&amp;lt;/tt&amp;gt; to the C compiler appropriate for your system and include&lt;br /&gt;
additional compiler flags if necessary. The flags that RSF typically uses are&lt;br /&gt;
in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C++ interface==&lt;br /&gt;
&lt;br /&gt;
The C++ clip function is listed below.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;valarray&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
    &lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&lt;br /&gt;
    int n1, n2;      // trace length, number of traces&lt;br /&gt;
    float clip;&lt;br /&gt;
    &lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it line by line. &lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Including &amp;quot;&amp;lt;tt&amp;gt;rsf.hh&amp;lt;/tt&amp;gt;&amp;quot; is required for accessing the RSF C++&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is required to initialize the internally stored&lt;br /&gt;
table of command-line arguments.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Two classes: &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;oRSF&amp;lt;/tt&amp;gt; are used to define input and&lt;br /&gt;
output files. For simplicity, the command-line parameters are also handled &lt;br /&gt;
as an &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; object, initialized with zero.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we read the data dimensions from the input RSF file object called&lt;br /&gt;
&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;: the trace length is a parameter called &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; and the&lt;br /&gt;
number of traces is the size of &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; remaining after excluding the&lt;br /&gt;
first dimension. It is extracted with the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter should be specified on the command line, for&lt;br /&gt;
example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. It is extracted with the &amp;lt;tt&amp;gt;get&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; class from the &amp;lt;tt&amp;gt;par&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace object has the single-precision floating-point type and is a&lt;br /&gt;
1-D array of length &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;. It is declared and allocated using&lt;br /&gt;
the &amp;lt;tt&amp;gt;valarray&amp;lt;/tt&amp;gt; template class from the standard C++ library.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we loop through the traces, read each trace from &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;, clip it&lt;br /&gt;
and write the output to &amp;lt;tt&amp;gt;out&amp;lt;/tt&amp;gt;.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the C++ program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
c++ clip.cc -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf++ -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;c++&amp;lt;/tt&amp;gt; to the C++ compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-77 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-77 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	program Clipit&lt;br /&gt;
	implicit none&lt;br /&gt;
	integer n1, n2, i1, i2, in, out&lt;br /&gt;
	integer sf_input, sf_output, sf_leftsize, sf_gettype&lt;br /&gt;
	logical sf_getfloat, sf_histint&lt;br /&gt;
	real clip, trace(1000)&lt;br /&gt;
&lt;br /&gt;
	call sf_init()&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&lt;br /&gt;
	stop&lt;br /&gt;
	end&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	call sf_init()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with a call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;, which initializes the&lt;br /&gt;
command-line interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output files are created with calls to&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;. Because of the absence of&lt;br /&gt;
derived types in Fortran-77, we use simple integer pointers to&lt;br /&gt;
represent RSF files. Both &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;&lt;br /&gt;
accept a character string, which may refer to a file name or a file&lt;br /&gt;
tag. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in&lt;br /&gt;
the standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard output.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). The function &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; checks the&lt;br /&gt;
type of data stored in the RSF file. We make sure that the type&lt;br /&gt;
corresponds to floating-point numbers. If not, the program is aborted&lt;br /&gt;
with an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. Since Fortran-77 cannot&lt;br /&gt;
easily handle dynamic allocation, we also need to check that&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is not larger than the size of the statically allocated&lt;br /&gt;
array. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function.  Calling &amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we&lt;br /&gt;
avoid the need to extract additional parameters for the hypercube&lt;br /&gt;
dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-77 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f77 clip.f -L$RSFROOT/lib -lrsff -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f77&amp;lt;/tt&amp;gt; to the Fortran compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-90 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-90 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
program Clipit&lt;br /&gt;
  use rsf&lt;br /&gt;
&lt;br /&gt;
  implicit none&lt;br /&gt;
  type (file)                      :: in, out&lt;br /&gt;
  integer                          :: n1, n2, i1, i2&lt;br /&gt;
  real                             :: clip&lt;br /&gt;
  real, dimension (:), allocatable :: trace&lt;br /&gt;
&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  call from_par(in,&amp;quot;n1&amp;quot;,n1)&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&lt;br /&gt;
  call from_par(&amp;quot;clip&amp;quot;,clip) ! command-line parameter &lt;br /&gt;
&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
     call rsf_write(out,trace)&lt;br /&gt;
  end do&lt;br /&gt;
end program Clipit&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  use rsf&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with importing the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is needed to initialize the command-line&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard input and output files are initialized with&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; functions. Both functions&lt;br /&gt;
accept optional arguments. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; extracts the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter&lt;br /&gt;
from the input file. Conceptually, the RSF data model is a&lt;br /&gt;
multidimensional hypercube.  The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace length. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; function.  Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in)&amp;lt;/tt&amp;gt; returns the total number of elements in the&lt;br /&gt;
hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;filesize(in,2)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt;, we avoid the need to extract additional parameters&lt;br /&gt;
for the hypercube dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. If we knew a good default&lt;br /&gt;
value for &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt;, we could specify it with an optional&lt;br /&gt;
argument, i.e. &amp;lt;tt&amp;gt;call~from_par(&amp;quot;clip&amp;quot;,clip,default)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-90 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f90 clip.f90 -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsff90 -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f90&amp;lt;/tt&amp;gt; to the Fortran-90 compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagasacar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The complete specification for the F90 API can be found [[Library_Reference#Fortran_90_API | on the Library Reference page]].&lt;br /&gt;
&lt;br /&gt;
==Python interface==&lt;br /&gt;
&lt;br /&gt;
The Python clip script is listed below.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&lt;br /&gt;
trace = numpy.zeros(n1,&#039;f&#039;)&lt;br /&gt;
&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script starts with importing the &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; module and the&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we initialize the command line interface and the standard input and&lt;br /&gt;
output files. We also make sure that the input file type is floating point.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We extract the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter from the input file.&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube.  The&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the fastest axis. If the input dataset&lt;br /&gt;
is a collection of traces, &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace&lt;br /&gt;
length. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of the &amp;lt;tt&amp;gt;Input&amp;lt;/tt&amp;gt; class1.  Calling &amp;lt;tt&amp;gt;size(0)&amp;lt;/tt&amp;gt; returns&lt;br /&gt;
the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;size(1)&amp;lt;/tt&amp;gt; returns the&lt;br /&gt;
number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.),&lt;br /&gt;
calling &amp;lt;tt&amp;gt;size(2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be specified,&lt;br /&gt;
for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
The python script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Interactive mode usage without graphics===&lt;br /&gt;
Madagascar&#039;s Python API can be used interactively too. Create an input dataset with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=10 n2=10 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start the python interpreter and paste the following to its command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy, rsf.api&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
data = data.transpose() # Example of numpy in action&lt;br /&gt;
&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.]&lt;br /&gt;
 [  1.   2.   3.   4.   5.   6.   7.   8.   9.  10.]&lt;br /&gt;
 [  2.   3.   4.   5.   6.   7.   8.   9.  10.  11.]&lt;br /&gt;
 [  3.   4.   5.   6.   7.   8.   9.  10.  11.  12.]&lt;br /&gt;
 [  4.   5.   6.   7.   8.   9.  10.  11.  12.  13.]&lt;br /&gt;
 [  5.   6.   7.   8.   9.  10.  11.  12.  13.  14.]&lt;br /&gt;
 [  6.   7.   8.   9.  10.  11.  12.  13.  14.  15.]&lt;br /&gt;
 [  7.   8.   9.  10.  11.  12.  13.  14.  15.  16.]&lt;br /&gt;
 [  8.   9.  10.  11.  12.  13.  14.  15.  16.  17.]&lt;br /&gt;
 [  9.  10.  11.  12.  13.  14.  15.  16.  17.  18.]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will also work in batch mode in a Python script, not only pasted to the interpreter&#039;s command line. &lt;br /&gt;
&lt;br /&gt;
===Graphics with Matplotlib===&lt;br /&gt;
Python can plot arrays directly from memory, without having to write a file to disk first. [http://matplotlib.sourceforge.net/ Matplotlib] is one of the [http://en.wikipedia.org/wiki/Category:Free_plotting_software several] packages that accomplish this. To create a figure, execute the code in the previous section, followed by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from pylab import *&lt;br /&gt;
imshow(data)&lt;br /&gt;
xlabel(&#039;X (m)&#039;)&lt;br /&gt;
ylabel(&#039;Y (m)&#039;)&lt;br /&gt;
title(&#039;Matplotlib example&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pop up a figure in an interactive session, after pasting to a Python command line the code shown before, also paste:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get Figure 1. The figure will pop up if you run the code in a script too, and the script will stop until the figure is manually closed. You must press the floppy disk button in order to save it. To have the image written to disk automatically, instead of &amp;lt;tt&amp;gt;show()&amp;lt;/tt&amp;gt; use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
savefig(&#039;myfile.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:matplotlib_imshow.png]]&lt;br /&gt;
&lt;br /&gt;
Putting it all together, here is a sample script reading a RSF file from stdin and printing out a figure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rsf.api, numpy, sys, pylab&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
&lt;br /&gt;
pylab.imshow(data)&lt;br /&gt;
pylab.savefig(&#039;out.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
===Python interfaces to the standalone programs===&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module offers a way to call Madagascar standalone programs (including graphics) elegantly from inside a Python program, interactively or in batch mode. The blog contains examples of running the &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module [http://www.ahay.org/rsflog/index.php?/archives/173-Extending-Python-interface.html from inside a SAGE notebook] or [http://www.ahay.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html from inside an iPython shell].&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module has &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;swig&amp;lt;/tt&amp;gt; as dependencies. On systems on which it is not possible to install these dependencies, the &amp;lt;tt&amp;gt;rsf.user.sf&amp;lt;/tt&amp;gt; module can be used instead (but with a different syntax and limited functionality).&lt;br /&gt;
&lt;br /&gt;
==MATLAB interface==&lt;br /&gt;
&lt;br /&gt;
The MATLAB clip function is listed below.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
function clip(in,out,clip)&lt;br /&gt;
%CLIP Clip the data&lt;br /&gt;
&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by figuring out the input file dimensions.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first dimension is the trace length, the product of all other&lt;br /&gt;
dimensions correspond to the number of traces.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we allocate the trace array and create an output file.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Available functions===&lt;br /&gt;
Only some of the functions in the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; library have received a MATLAB interface. These functions are &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt;. All these functions except &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; have been illustrated in the example above.&lt;br /&gt;
===Compiling===&lt;br /&gt;
The MATLAB script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Java Interface==&lt;br /&gt;
There are two interfaces to Java that are available.  New codes should be written to use the SWIG interface ONLY.  The older interface (using the MINES JTK) is deprecated, and is only provided while users migrate their code to the new interface.&lt;br /&gt;
&lt;br /&gt;
===SWIG===&lt;br /&gt;
&lt;br /&gt;
To install the SWIG interface:&lt;br /&gt;
&lt;br /&gt;
1 - Download the Java Standard Development Kit (JDK).  Installation varies by platform.&lt;br /&gt;
&lt;br /&gt;
2 - Create the JAVA_HOME environment variable for your shell.  This should point to the directory where the JDK was installed. Example (for Ubuntu 10.04):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export JAVA_HOME=/usr/lib/jvm/java-6-opensdk&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
3 - Reconfigure Madagascar:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
4 - Reinstall Madagascar (Ignore the compilation warnings for Java files):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
scons; scons install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation creates two files:  $RSFROOT/lib/libjrsf.so and $RSFROOT/lib/rsf.jar .&lt;br /&gt;
&lt;br /&gt;
Make sure that you set your LD_LIBRARY_PATH to include $RSFROOT/lib.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A short demonstration of the interface follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.RSF;&lt;br /&gt;
import rsf.Input;&lt;br /&gt;
import rsf.Output;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset. */&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    static {&lt;br /&gt;
        System.loadLibrary(&amp;quot;jrsf&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         RSF par = new RSF(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         Input input = new Input(&amp;quot;in&amp;quot;);&lt;br /&gt;
         Output output = new Output(&amp;quot;out&amp;quot;);&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        // Read our input header&lt;br /&gt;
        int n3 = input.getN(3);&lt;br /&gt;
        int n2 = input.getN(2);&lt;br /&gt;
        int n1 = input.getN(1);&lt;br /&gt;
        //Perform clipping operation on a single trace and write out.&lt;br /&gt;
        float[] data = new float[n1];&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                input.read(data);&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    if (data[k] &amp;gt; clip) data[k] = clip;&lt;br /&gt;
                    else if (data[k] &amp;lt; -clip) data[k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
                output.write(data);&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         output.setN(1,n1);&lt;br /&gt;
         output.setN(2,n2);&lt;br /&gt;
         output.setN(3,n3);&lt;br /&gt;
         input.close();&lt;br /&gt;
         output.close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are only three classes in the interface:&lt;br /&gt;
&lt;br /&gt;
1 -- RSF - The command line argument parser, and the initializer for the native interface.  An RSF object MUST be instantiated BEFORE instantiating an Input or Output object.&lt;br /&gt;
&lt;br /&gt;
2 -- Input - An object that provides read access to an RSF file.  &lt;br /&gt;
&lt;br /&gt;
3 -- Output - An object that provides write access to an RSF file.&lt;br /&gt;
&lt;br /&gt;
Additionally, the shared library (libjrsf.so or libjrsf.dll) must be included via the System.loadLibrary(&amp;quot;jrsf&amp;quot;); as the first command in the file.&lt;br /&gt;
&lt;br /&gt;
To compile on the command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $RSFROOT/lib Clip.java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To include this as part of a SCons script (SConstruct):&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500 l1=1000&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;dat Clip.class&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s Clip clip=0.5&lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;))&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that we compile Clip.java using the SCons Java builder.  To execute the command, we have to locate the &amp;quot;java&amp;quot; command, which we do using WhereIs(&#039;java&#039;).  Then we execute the class name, and pass any command line arguments as usual.  The files are read from standard in for this program and written to standard out.  &lt;br /&gt;
&lt;br /&gt;
Please see the [[Library Reference]] for more details on the functions available in the SWIG API.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: Additional Java packages can included in SCons automatically by setting the CLASSPATH environment variable to point to the JAR files that they are contained in.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Mines JTK===&lt;br /&gt;
&#039;&#039;&#039;THIS INTERFACE IS DEPRECATED AND ONLY PROVIDED AS A REFERENCE.  THIS INTERFACE IS NO LONGER SUPPORTED AND WILL BE REMOVED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This interface may still be compiled by specifying the MINESJTK environment variable. &lt;br /&gt;
&lt;br /&gt;
The interface to Java is less full featured than others.  Presently, it only allows you to read RSF files with fewer than 4-dimensions into Java, and then export RSF files.  &#039;&#039;&#039;The Java interface does not support reading from standard in, or writing from standard out.  Therefore, the Java Interface does not support piping either.&#039;&#039;&#039; The Java interface at present treats all values as floats, and does not have support for complex numbers.  Java programs are not parsed for self-doc information like other programs are either.  Using javadoc may be a viable alternative to creating a parsing engine for Java programs.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, the JAR file rsf.jar will be added to your $RSFROOT/lib folder.  &lt;br /&gt;
&lt;br /&gt;
There are two ways to access the API:&lt;br /&gt;
&lt;br /&gt;
1 - From the command line:  point the classpath at BOTH compile and runtime to this location on the command line.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test.java &lt;br /&gt;
java -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test arg1=... arg2=... arg3=...&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2 - From within a SConstruct script:  BOTH the path for the API ($RSFROOT/lib) and the path to the Mines JTK ($MINESJTK) are automatically added to the environment variable CLASSPATH and JAVACLASSPATH for executions made within an SConstruct.  Additionally, any additional classes that are already in the CLASSPATH environmental variable in the shell that you launch from will be added to your classpath.  This allows you to include additional libraries automatically within your Java programs.  The local directory (.) is also included in the CLASSPATH.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;Clip.class dat&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s ${SOURCES[0].filebase} clip=0.5 &lt;br /&gt;
    in=${SOURCES[1]} out=$TARGET &lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;),stdin=0,stdout=-1)&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface itself is fairly straightforward.  More details on the methods exposed by the API can be found at the [[Library_Reference#Java_API | Library Reference]].&lt;br /&gt;
&lt;br /&gt;
Data clipping, argument parsing, and IO example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Par;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset.&lt;br /&gt;
&lt;br /&gt;
Presently, there is no automatic self-documentation generation for use&lt;br /&gt;
with sfdoc.  Javadoc may be a better way to generate self-doc for Java&lt;br /&gt;
programs.&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         Par par = new Par(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         String input = par.getString(&amp;quot;in&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         // If the input file name is nothing, then quit!&lt;br /&gt;
         if (input.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find input file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
         //If the output file name is nothing, then quit!&lt;br /&gt;
         String output = par.getString(&amp;quot;out&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         if (output.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find output file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        //Read our header file.&lt;br /&gt;
         Header header = Reader.readHeader(input);&lt;br /&gt;
        // Read our binary data.&lt;br /&gt;
         float[][][] data = Reader.readBinary3D(header);&lt;br /&gt;
        //Initialize our array values.&lt;br /&gt;
         int n3 = header.getN(3);&lt;br /&gt;
         int n2 = header.getN(2);&lt;br /&gt;
         int n1 = header.getN(1);&lt;br /&gt;
        //Perform clipping operation.&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    float trace = data[i][j][k];&lt;br /&gt;
                    if (trace &amp;gt; clip) data[i][j][k] = clip;&lt;br /&gt;
                    else if (trace &amp;lt; -clip) data[i][j][k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
        //Write our data out, using the same header values to the file&lt;br /&gt;
        //located at: output.&lt;br /&gt;
         Writer.writeRSF(header,data,output);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to read a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;junk.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to write a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
                &lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;test.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;test2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to create a dataset from scratch from within Java, then you can create an array of data, modify the values, create a header, and then write it out to rsf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                int n1 = 20;&lt;br /&gt;
                int n2 = 40;&lt;br /&gt;
                float[][] data = new float[n2][n1]; &lt;br /&gt;
                //The order for dimensions is reversed, because RSF stores them as column-major arrays (see Python API).&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
&lt;br /&gt;
                Header header = new Header();&lt;br /&gt;
                header.setN(1,n1);&lt;br /&gt;
                /* We set the values using the proper RSF number for the dimension, instead of the Java array index.&lt;br /&gt;
                   Example:  RSF Dimension 1, corresponds to array index 0 in Java.&lt;br /&gt;
                             However, we set the values using index 1.  The mapping is handled behind the scenes.&lt;br /&gt;
                 */&lt;br /&gt;
                header.setN(2,n2); &lt;br /&gt;
                header.setDelta(1,0.0);&lt;br /&gt;
                header.setLabel(1,&amp;quot;time&amp;quot;);&lt;br /&gt;
                header.setUnits(1,&amp;quot;s&amp;quot;);&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;junk2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=1972</id>
		<title>Guide to madagascar API</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Guide_to_madagascar_API&amp;diff=1972"/>
		<updated>2011-08-06T02:05:16Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Graphics with Matplotlib */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_555071_XS.jpg|right|]]&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;font size=&amp;quot;-1&amp;quot;&amp;gt;&#039;&#039;This page was created from the LaTeX source in [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/book/rsf/rsf/api.tex?view=markup book/rsf/rsf/api.tex] using [[latex2wiki]]&#039;&#039;&amp;lt;/font&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This guide explains the RSF programming interface.  See the &#039;&#039;&#039;[[Library_Reference | Library Reference]]&#039;&#039;&#039; for more information on how to use the particular APIs.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
To work with RSF files in your own programs, you may need to use an&lt;br /&gt;
appropriate programming interface. We will demonstrate the interface in&lt;br /&gt;
different languages using a simple example. The example is a clipping program.&lt;br /&gt;
It reads and writes RSF files and accesses parameters both from the input file&lt;br /&gt;
and the command line. The input is processed trace by trace. This is not&lt;br /&gt;
necessarily the most efficient approach&amp;lt;ref&amp;gt;Compare with the [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/filt/proc/Mclip.c?view=markup library clip program].&amp;lt;/ref&amp;gt; but it suffices for a simple demonstration.&lt;br /&gt;
&lt;br /&gt;
==Installation== &lt;br /&gt;
Only the C interface is installed by default. To install other APIs, use &amp;lt;tt&amp;gt;API=&amp;lt;/tt&amp;gt;&lt;br /&gt;
parameter in the RSF configuration. For example, to install C++ and&lt;br /&gt;
Fortran-90 API bindings in addition to the basic package, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./configure API=c++,fortran-90&lt;br /&gt;
scons install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The configuration parameters are stored in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C interface==&lt;br /&gt;
&lt;br /&gt;
The C clip function is listed below.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    int n1, n2, i1, i2;&lt;br /&gt;
    float clip, *trace=NULL;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    sf_close();&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.h&amp;gt;&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The include preprocessing directive is required to access the RSF interface. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    sf_file in=NULL, out=NULL; /* Input and output files */&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF data files are defined with an abstract &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; data type. An&lt;br /&gt;
abstract data type means that the contents of it are not publicly declared,&lt;br /&gt;
and all operations on &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; objects should be performed with&lt;br /&gt;
library functions. This is analogous to &amp;lt;tt&amp;gt;FILE *&amp;lt;/tt&amp;gt; data type used in&lt;br /&gt;
&amp;lt;tt&amp;gt;stdio.h&amp;lt;/tt&amp;gt; and as close as C gets to an object-oriented style of&lt;br /&gt;
programming (Roberts, 1998&amp;lt;ref&amp;gt;Roberts, E. S.,  1998, Programming abstractions in C: Addison-Wesley.&amp;lt;/ref&amp;gt;).&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* Initialize RSF */&lt;br /&gt;
    sf_init(argc,argv);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any of the other functions, you must call&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;. This function parses the command line and&lt;br /&gt;
initializes an internally stored table of command-line parameters.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* standard input */&lt;br /&gt;
    in = sf_input(&amp;quot;in&amp;quot;);&lt;br /&gt;
    /* standard output */&lt;br /&gt;
    out = sf_output(&amp;quot;out&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output RSF file objects are created with &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt; constructor functions. Both these functions take a string&lt;br /&gt;
argument. The string may refer to a file name or a file tag. For example, if&lt;br /&gt;
the command line contains &amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the standard&lt;br /&gt;
output. &lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* check that the input is float */&lt;br /&gt;
    if (SF_FLOAT != sf_gettype(in)) &lt;br /&gt;
	sf_error(&amp;quot;Need float input&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). We extract the data type of the input file&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; function and check if it&lt;br /&gt;
represents floating point numbers. If not, the program is aborted with&lt;br /&gt;
an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* n1 is the fastest dimension (trace length) */&lt;br /&gt;
    if (!sf_histint(in,&amp;quot;n1&amp;quot;,&amp;amp;n1)) &lt;br /&gt;
	sf_error(&amp;quot;No n1= in input&amp;quot;);&lt;br /&gt;
    /* leftsize gets n2*n3*n4*... (the number of traces) */&lt;br /&gt;
    n2 = sf_leftsize(in,1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function. Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt; returns the total number of elements in&lt;br /&gt;
the hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product&lt;br /&gt;
of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we avoid the need&lt;br /&gt;
to extract additional parameters for the hypercube dimensions that we&lt;br /&gt;
are not interested in.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* parameter from the command line (i.e. clip=1.5 ) */&lt;br /&gt;
    if (!sf_getfloat(&amp;quot;clip&amp;quot;,&amp;amp;clip)) sf_error(&amp;quot;Need clip=&amp;quot;);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* allocate floating point array */&lt;br /&gt;
    trace = sf_floatalloc (n1);&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Next, we allocate an array of floating-point numbers to store a trace&lt;br /&gt;
with the library &amp;lt;tt&amp;gt;sf_floatalloc&amp;lt;/tt&amp;gt; function. Unlike the standard&lt;br /&gt;
&amp;lt;tt&amp;gt;malloc&amp;lt;/tt&amp;gt; the RSF allocation function checks for errors and&lt;br /&gt;
either terminates the program or returns a valid pointer.&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
    /* loop over traces */&lt;br /&gt;
    for (i2=0; i2 &amp;lt; n2; i2++) {&lt;br /&gt;
&lt;br /&gt;
	/*read a trace */&lt;br /&gt;
	sf_floatread(trace,n1,in);&lt;br /&gt;
&lt;br /&gt;
	/* loop over samples */&lt;br /&gt;
	for (i1=0; i1 &amp;lt; n1; i1++) {&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]= clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	/* write a trace */&lt;br /&gt;
	sf_floatwrite(trace,n1,out);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The rest of the program is straightforward. We loop over all available&lt;br /&gt;
traces, read each trace, clip it and right the output out. The syntax&lt;br /&gt;
of &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt; functions is&lt;br /&gt;
similar to the syntax of the C standard &amp;lt;tt&amp;gt;fread&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;fwrite&amp;lt;/tt&amp;gt; function except that the type of the element is&lt;br /&gt;
specified explicitly in the function name and that the input and&lt;br /&gt;
output files have the RSF type &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;c&amp;gt;&lt;br /&gt;
sf_close();&lt;br /&gt;
exit(0)&lt;br /&gt;
&amp;lt;/c&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We explicitly close the input file to avoid leaving a stale temporary file in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; if the program is called in a pipe sequence. Then, we close the program by sending the shell the Unix code that tells it no errors were encountered. &lt;br /&gt;
&lt;br /&gt;
Note that this is an introductory example, optimized for clarity, not execution speed. For advanced techniques, see [[Madagascar Code Patterns]].&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt; program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cc clip.c -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;cc&amp;lt;/tt&amp;gt; to the C compiler appropriate for your system and include&lt;br /&gt;
additional compiler flags if necessary. The flags that RSF typically uses are&lt;br /&gt;
in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==C++ interface==&lt;br /&gt;
&lt;br /&gt;
The C++ clip function is listed below.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
/* Clip the data. */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;valarray&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
    &lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&lt;br /&gt;
    int n1, n2;      // trace length, number of traces&lt;br /&gt;
    float clip;&lt;br /&gt;
    &lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    exit(0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it line by line. &lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
#include &amp;lt;rsf.hh&amp;gt;&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Including &amp;quot;&amp;lt;tt&amp;gt;rsf.hh&amp;lt;/tt&amp;gt;&amp;quot; is required for accessing the RSF C++&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    sf_init(argc,argv); // Initialize RSF&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is required to initialize the internally stored&lt;br /&gt;
table of command-line arguments.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    iRSF par(0), in; // input parameter, file&lt;br /&gt;
    oRSF out;        // output file&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Two classes: &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;oRSF&amp;lt;/tt&amp;gt; are used to define input and&lt;br /&gt;
output files. For simplicity, the command-line parameters are also handled &lt;br /&gt;
as an &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; object, initialized with zero.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    in.get(&amp;quot;n1&amp;quot;,n1);&lt;br /&gt;
    n2=in.size(1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we read the data dimensions from the input RSF file object called&lt;br /&gt;
&amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;: the trace length is a parameter called &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; and the&lt;br /&gt;
number of traces is the size of &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt; remaining after excluding the&lt;br /&gt;
first dimension. It is extracted with the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    par.get(&amp;quot;clip&amp;quot;,clip); // parameter from the command line&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The clip parameter should be specified on the command line, for&lt;br /&gt;
example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. It is extracted with the &amp;lt;tt&amp;gt;get&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of &amp;lt;tt&amp;gt;iRSF&amp;lt;/tt&amp;gt; class from the &amp;lt;tt&amp;gt;par&amp;lt;/tt&amp;gt; object.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    std::valarray&amp;lt;float&amp;gt; trace(n1);&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The trace object has the single-precision floating-point type and is a&lt;br /&gt;
1-D array of length &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;. It is declared and allocated using&lt;br /&gt;
the &amp;lt;tt&amp;gt;valarray&amp;lt;/tt&amp;gt; template class from the standard C++ library.&lt;br /&gt;
&amp;lt;cpp&amp;gt;&lt;br /&gt;
    for (int i2=0; i2 &amp;lt; n2; i2++) { // loop over traces&lt;br /&gt;
	in &amp;gt;&amp;gt; trace; // read a trace&lt;br /&gt;
&lt;br /&gt;
	for (int i1=0; i1 &amp;lt; n1; i1++) { // loop over samples&lt;br /&gt;
	    if      (trace[i1] &amp;gt;  clip) trace[i1]=clip;&lt;br /&gt;
	    else if (trace[i1] &amp;lt; -clip) trace[i1]=-clip;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	out &amp;lt;&amp;lt; trace; // write a trace&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we loop through the traces, read each trace from &amp;lt;tt&amp;gt;in&amp;lt;/tt&amp;gt;, clip it&lt;br /&gt;
and write the output to &amp;lt;tt&amp;gt;out&amp;lt;/tt&amp;gt;.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the C++ program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
c++ clip.cc -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsf++ -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;c++&amp;lt;/tt&amp;gt; to the C++ compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-77 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-77 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	program Clipit&lt;br /&gt;
	implicit none&lt;br /&gt;
	integer n1, n2, i1, i2, in, out&lt;br /&gt;
	integer sf_input, sf_output, sf_leftsize, sf_gettype&lt;br /&gt;
	logical sf_getfloat, sf_histint&lt;br /&gt;
	real clip, trace(1000)&lt;br /&gt;
&lt;br /&gt;
	call sf_init()&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&lt;br /&gt;
	stop&lt;br /&gt;
	end&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	call sf_init()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with a call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt;, which initializes the&lt;br /&gt;
command-line interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	in = sf_input(&amp;quot;in&amp;quot;)&lt;br /&gt;
	out = sf_output(&amp;quot;out&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input and output files are created with calls to&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;. Because of the absence of&lt;br /&gt;
derived types in Fortran-77, we use simple integer pointers to&lt;br /&gt;
represent RSF files. Both &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_output&amp;lt;/tt&amp;gt;&lt;br /&gt;
accept a character string, which may refer to a file name or a file&lt;br /&gt;
tag. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable. Two tags are special: &amp;lt;tt&amp;gt;&amp;quot;in&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in&lt;br /&gt;
the standard input and &amp;lt;tt&amp;gt;&amp;quot;out&amp;quot;&amp;lt;/tt&amp;gt; refers to the file in the&lt;br /&gt;
standard output.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (3 .ne. sf_gettype(in)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need float input&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSF files can store data of different types (character, integer,&lt;br /&gt;
floating point, complex). The function &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; checks the&lt;br /&gt;
type of data stored in the RSF file. We make sure that the type&lt;br /&gt;
corresponds to floating-point numbers. If not, the program is aborted&lt;br /&gt;
with an error message, using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.  It is&lt;br /&gt;
generally a good idea to check the input for user errors and, if they&lt;br /&gt;
cannot be corrected, to take a safe exit.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_histint(in,&amp;quot;n1&amp;quot;,n1)) then&lt;br /&gt;
	   call sf_error(&amp;quot;No n1= in input&amp;quot;)&lt;br /&gt;
	else if (n1 &amp;gt; 1000) then&lt;br /&gt;
	   call sf_error(&amp;quot;n1 is too long&amp;quot;)&lt;br /&gt;
	end if&lt;br /&gt;
	n2 = sf_leftsize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube. By&lt;br /&gt;
convention, the dimensions of the cube are stored in &amp;lt;tt&amp;gt;n1=&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n2=&amp;lt;/tt&amp;gt;, etc. parameters. The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; refers to the trace length. We extract it using the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt; function (integer parameter from history) and&lt;br /&gt;
abort if no value for &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is found. Since Fortran-77 cannot&lt;br /&gt;
easily handle dynamic allocation, we also need to check that&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; is not larger than the size of the statically allocated&lt;br /&gt;
array. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt; function.  Calling &amp;lt;tt&amp;gt;sf_leftsize(in,0)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,1)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
etc.), calling &amp;lt;tt&amp;gt;sf_leftsize(in,2)&amp;lt;/tt&amp;gt; returns the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;, we&lt;br /&gt;
avoid the need to extract additional parameters for the hypercube&lt;br /&gt;
dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	if (.not. sf_getfloat(&amp;quot;clip&amp;quot;,clip)) &lt;br /&gt;
     &amp;amp;  call sf_error(&amp;quot;Need clip=&amp;quot;)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. The parameter has the&lt;br /&gt;
&amp;lt;tt&amp;gt;float&amp;lt;/tt&amp;gt; type, therefore we read it with the&lt;br /&gt;
&amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt; function. If no &amp;lt;tt&amp;gt;clip=&amp;lt;/tt&amp;gt; parameter is&lt;br /&gt;
found among the command line arguments, the program is aborted with an&lt;br /&gt;
error message using the &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
	do 10 i2=1, n2&lt;br /&gt;
	   call sf_floatread(trace,n1,in)&lt;br /&gt;
&lt;br /&gt;
	   do 20 i1=1, n1&lt;br /&gt;
	      if (trace(i1) &amp;gt;  clip) then&lt;br /&gt;
		 trace(i1)=clip&lt;br /&gt;
	      else if (trace(i1) &amp;lt; -clip) then&lt;br /&gt;
		 trace(i1)=-clip&lt;br /&gt;
	      end if&lt;br /&gt;
 20	   continue&lt;br /&gt;
&lt;br /&gt;
	   call sf_floatwrite(trace,n1,out)&lt;br /&gt;
 10	continue&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-77 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f77 clip.f -L$RSFROOT/lib -lrsff -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f77&amp;lt;/tt&amp;gt; to the Fortran compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagascar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fortran-90 interface==&lt;br /&gt;
&lt;br /&gt;
The Fortran-90 clip function is listed below.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
program Clipit&lt;br /&gt;
  use rsf&lt;br /&gt;
&lt;br /&gt;
  implicit none&lt;br /&gt;
  type (file)                      :: in, out&lt;br /&gt;
  integer                          :: n1, n2, i1, i2&lt;br /&gt;
  real                             :: clip&lt;br /&gt;
  real, dimension (:), allocatable :: trace&lt;br /&gt;
&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  call from_par(in,&amp;quot;n1&amp;quot;,n1)&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&lt;br /&gt;
  call from_par(&amp;quot;clip&amp;quot;,clip) ! command-line parameter &lt;br /&gt;
&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
     call rsf_write(out,trace)&lt;br /&gt;
  end do&lt;br /&gt;
end program Clipit&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  use rsf&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program starts with importing the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  call sf_init()            ! initialize RSF&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; is needed to initialize the command-line&lt;br /&gt;
interface.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  in = rsf_input()&lt;br /&gt;
  out = rsf_output()&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard input and output files are initialized with&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; functions. Both functions&lt;br /&gt;
accept optional arguments. For example, if the command line contains&lt;br /&gt;
&amp;lt;tt&amp;gt;vel=velocity.rsf&amp;lt;/tt&amp;gt;, then both&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf_input(&amp;quot;velocity.rsf&amp;quot;)&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_input(&amp;quot;vel&amp;quot;)&amp;lt;/tt&amp;gt; are&lt;br /&gt;
acceptable.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  if (sf_float /= gettype(in)) call sf_error(&amp;quot;Need float type&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; extracts the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter&lt;br /&gt;
from the input file. Conceptually, the RSF data model is a&lt;br /&gt;
multidimensional hypercube.  The &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the&lt;br /&gt;
fastest axis. If the input dataset is a collection of traces,&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace length. We could proceed in a&lt;br /&gt;
similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are&lt;br /&gt;
interested in the total number of traces, like in the clip example, a&lt;br /&gt;
shortcut is to use the &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; function.  Calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in)&amp;lt;/tt&amp;gt; returns the total number of elements in the&lt;br /&gt;
hypercube (the product of &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize(in,1)&amp;lt;/tt&amp;gt; returns the number of traces (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;filesize(in,2)&amp;lt;/tt&amp;gt;&lt;br /&gt;
returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc. By calling&lt;br /&gt;
&amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt;, we avoid the need to extract additional parameters&lt;br /&gt;
for the hypercube dimensions that we are not interested in.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  n2 = filesize(in,1)&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be&lt;br /&gt;
specified, for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;. If we knew a good default&lt;br /&gt;
value for &amp;lt;tt&amp;gt;clip&amp;lt;/tt&amp;gt;, we could specify it with an optional&lt;br /&gt;
argument, i.e. &amp;lt;tt&amp;gt;call~from_par(&amp;quot;clip&amp;quot;,clip,default)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;fortran&amp;gt;&lt;br /&gt;
  allocate (trace (n1))&lt;br /&gt;
&lt;br /&gt;
  do i2=1, n2                ! loop over traces&lt;br /&gt;
     call rsf_read(in,trace)&lt;br /&gt;
     &lt;br /&gt;
     where (trace &amp;gt;  clip) trace =  clip&lt;br /&gt;
     where (trace &amp;lt; -clip) trace = -clip&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/fortran&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Compiling===&lt;br /&gt;
To compile the Fortran-90 program, run&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
f90 clip.f90 -I&amp;amp;#36;RSFROOT/include -L&amp;amp;#36;RSFROOT/lib -lrsff90 -lrsf -lm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Change &amp;lt;tt&amp;gt;f90&amp;lt;/tt&amp;gt; to the Fortran-90 compiler appropriate for your system and&lt;br /&gt;
include additional compiler flags if necessary. The flags that RSF typically&lt;br /&gt;
uses are in &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/share/madagasacar/etc/config.py&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The complete specification for the F90 API can be found [[Library_Reference#Fortran_90_API | on the Library Reference page]].&lt;br /&gt;
&lt;br /&gt;
==Python interface==&lt;br /&gt;
&lt;br /&gt;
The Python clip script is listed below.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&lt;br /&gt;
trace = numpy.zeros(n1,&#039;f&#039;)&lt;br /&gt;
&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy&lt;br /&gt;
import rsf.api as rsf&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script starts with importing the &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; module and the&lt;br /&gt;
&amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
par = rsf.Par()&lt;br /&gt;
input  = rsf.Input()&lt;br /&gt;
output = rsf.Output()&lt;br /&gt;
assert &#039;float&#039; == input.type&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we initialize the command line interface and the standard input and&lt;br /&gt;
output files. We also make sure that the input file type is floating point.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.size(1)&lt;br /&gt;
assert n1&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We extract the &amp;quot;&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;&amp;quot; parameter from the input file.&lt;br /&gt;
Conceptually, the RSF data model is a multidimensional hypercube.  The&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; parameter refers to the fastest axis. If the input dataset&lt;br /&gt;
is a collection of traces, &amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt; corresponds to the trace&lt;br /&gt;
length. We could proceed in a similar fashion, extracting &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc. If we are interested in the total number of traces,&lt;br /&gt;
like in the clip example, a shortcut is to use the &amp;lt;tt&amp;gt;size&amp;lt;/tt&amp;gt;&lt;br /&gt;
method of the &amp;lt;tt&amp;gt;Input&amp;lt;/tt&amp;gt; class1.  Calling &amp;lt;tt&amp;gt;size(0)&amp;lt;/tt&amp;gt; returns&lt;br /&gt;
the total number of elements in the hypercube (the product of&lt;br /&gt;
&amp;lt;tt&amp;gt;n1&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, etc.), calling &amp;lt;tt&amp;gt;size(1)&amp;lt;/tt&amp;gt; returns the&lt;br /&gt;
number of traces (the product of &amp;lt;tt&amp;gt;n2&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;, etc.),&lt;br /&gt;
calling &amp;lt;tt&amp;gt;size(2)&amp;lt;/tt&amp;gt; returns the product of &amp;lt;tt&amp;gt;n3&amp;lt;/tt&amp;gt;,&lt;br /&gt;
&amp;lt;tt&amp;gt;n4&amp;lt;/tt&amp;gt;, etc.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
clip = par.float(&amp;quot;clip&amp;quot;)&lt;br /&gt;
assert clip&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The clip parameter is read from the command line, where it can be specified,&lt;br /&gt;
for example, as &amp;lt;tt&amp;gt;clip=10&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
for i2 in xrange(n2): # loop over traces&lt;br /&gt;
    input.read(trace)&lt;br /&gt;
    trace = numpy.clip(trace,-clip,clip)&lt;br /&gt;
    output.write(trace)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
&lt;br /&gt;
===Compiling===&lt;br /&gt;
The python script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Interactive mode usage without graphics===&lt;br /&gt;
Madagascar&#039;s Python API can be used interactively too. Create an input dataset with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sfmath n1=10 n2=10 output=x1+x2 &amp;gt; test.rsf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, start the python interpreter and paste the following to its command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import numpy, rsf.api&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
data = data.transpose() # Example of numpy in action&lt;br /&gt;
&lt;br /&gt;
print data&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.]&lt;br /&gt;
 [  1.   2.   3.   4.   5.   6.   7.   8.   9.  10.]&lt;br /&gt;
 [  2.   3.   4.   5.   6.   7.   8.   9.  10.  11.]&lt;br /&gt;
 [  3.   4.   5.   6.   7.   8.   9.  10.  11.  12.]&lt;br /&gt;
 [  4.   5.   6.   7.   8.   9.  10.  11.  12.  13.]&lt;br /&gt;
 [  5.   6.   7.   8.   9.  10.  11.  12.  13.  14.]&lt;br /&gt;
 [  6.   7.   8.   9.  10.  11.  12.  13.  14.  15.]&lt;br /&gt;
 [  7.   8.   9.  10.  11.  12.  13.  14.  15.  16.]&lt;br /&gt;
 [  8.   9.  10.  11.  12.  13.  14.  15.  16.  17.]&lt;br /&gt;
 [  9.  10.  11.  12.  13.  14.  15.  16.  17.  18.]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will also work in batch mode in a Python script, not only pasted to the interpreter&#039;s command line. &lt;br /&gt;
&lt;br /&gt;
===Graphics with Matplotlib===&lt;br /&gt;
Python can plot arrays directly from memory, without having to write a file to disk first. [http://matplotlib.sourceforge.net/ Matplotlib] is one of the [http://en.wikipedia.org/wiki/Category:Free_plotting_software several] packages that accomplish this. To create a figure, execute the code in the previous section, followed by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from pylab import *&lt;br /&gt;
imshow(data)&lt;br /&gt;
xlabel(&#039;X (m)&#039;)&lt;br /&gt;
ylabel(&#039;Y (m)&#039;)&lt;br /&gt;
title(&#039;Matplotlib example&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to pop up a figure in an interactive session, after pasting to a Python command line the code shown before, also paste:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
show()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will get Figure 1. The figure will pop up if you run the code in a script too, and the script will stop until the figure is manually closed. You must press the floppy disk button in order to save it. To have the image written to disk automatically, instead of &amp;lt;tt&amp;gt;show()&amp;lt;/tt&amp;gt; use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
savefig(&#039;myfile.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:matplotlib_imshow.png]]&lt;br /&gt;
&lt;br /&gt;
Putting it all together, here is a sample script reading a RSF file from stdin and printing out a figure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rsf.api, numpy, sys, pylab&lt;br /&gt;
&lt;br /&gt;
input = rsf.api.Input(&#039;test.rsf&#039;)&lt;br /&gt;
n1 = input.int(&amp;quot;n1&amp;quot;)&lt;br /&gt;
n2 = input.int(&amp;quot;n2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
data = numpy.zeros((n2,n1),&#039;f&#039;)&lt;br /&gt;
input.read(data)&lt;br /&gt;
&lt;br /&gt;
pylab.imshow(data)&lt;br /&gt;
pylab.savefig(&#039;out.png&#039;)&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
===Python interfaces to the Madagascar standalone programs===&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module offers a way to call Madagascar standalone programs (including graphics) elegantly from inside a Python program, interactively or in batch mode. The blog contains examples of running the &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module [http://www.ahay.org/rsflog/index.php?/archives/173-Extending-Python-interface.html from inside a SAGE notebook] or [http://www.ahay.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html from inside an iPython shell].&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;m8r&amp;lt;/tt&amp;gt; module has &amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;swig&amp;lt;/tt&amp;gt; as dependencies. On systems on which it is not possible to install these dependencies, the &amp;lt;tt&amp;gt;rsf.user.sf&amp;lt;/tt&amp;gt; module can be used instead (but with a different syntax and limited functionality).&lt;br /&gt;
&lt;br /&gt;
==MATLAB interface==&lt;br /&gt;
&lt;br /&gt;
The MATLAB clip function is listed below.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
function clip(in,out,clip)&lt;br /&gt;
%CLIP Clip the data&lt;br /&gt;
&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let us examine it in detail. &lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
dims = rsf_dim(in);&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start by figuring out the input file dimensions.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
n1 = dims(1);           % trace length&lt;br /&gt;
n2 = prod(dims(2:end)); % number of traces&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first dimension is the trace length, the product of all other&lt;br /&gt;
dimensions correspond to the number of traces.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
trace = 1:n1;           % allocate trace&lt;br /&gt;
rsf_create(out,in)      % create an output file&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we allocate the trace array and create an output file.&lt;br /&gt;
&amp;lt;matlab&amp;gt;&lt;br /&gt;
for i2 = 1:n2           % loop over traces&lt;br /&gt;
    rsf_read(trace,in,&#039;same&#039;);&lt;br /&gt;
    trace(trace &amp;gt;   clip) =  clip;&lt;br /&gt;
    trace(trace &amp;lt; - clip) = -clip;&lt;br /&gt;
    rsf_write(trace,out,&#039;same&#039;);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/matlab&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, we do the actual work: loop over input traces, reading,&lt;br /&gt;
clipping, and writing out each trace.&lt;br /&gt;
===Available functions===&lt;br /&gt;
Only some of the functions in the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; library have received a MATLAB interface. These functions are &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt;. All these functions except &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; have been illustrated in the example above.&lt;br /&gt;
===Compiling===&lt;br /&gt;
The MATLAB script does not require compilation. Simply make sure that&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT/lib&amp;lt;/tt&amp;gt; is in &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;LD_LIBRARY_PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Java Interface==&lt;br /&gt;
There are two interfaces to Java that are available.  New codes should be written to use the SWIG interface ONLY.  The older interface (using the MINES JTK) is deprecated, and is only provided while users migrate their code to the new interface.&lt;br /&gt;
&lt;br /&gt;
===SWIG===&lt;br /&gt;
&lt;br /&gt;
To install the SWIG interface:&lt;br /&gt;
&lt;br /&gt;
1 - Download the Java Standard Development Kit (JDK).  Installation varies by platform.&lt;br /&gt;
&lt;br /&gt;
2 - Create the JAVA_HOME environment variable for your shell.  This should point to the directory where the JDK was installed. Example (for Ubuntu 10.04):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export JAVA_HOME=/usr/lib/jvm/java-6-opensdk&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
3 - Reconfigure Madagascar:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
4 - Reinstall Madagascar (Ignore the compilation warnings for Java files):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
scons; scons install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation creates two files:  $RSFROOT/lib/libjrsf.so and $RSFROOT/lib/rsf.jar .&lt;br /&gt;
&lt;br /&gt;
Make sure that you set your LD_LIBRARY_PATH to include $RSFROOT/lib.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A short demonstration of the interface follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.RSF;&lt;br /&gt;
import rsf.Input;&lt;br /&gt;
import rsf.Output;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset. */&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    static {&lt;br /&gt;
        System.loadLibrary(&amp;quot;jrsf&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         RSF par = new RSF(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         Input input = new Input(&amp;quot;in&amp;quot;);&lt;br /&gt;
         Output output = new Output(&amp;quot;out&amp;quot;);&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        // Read our input header&lt;br /&gt;
        int n3 = input.getN(3);&lt;br /&gt;
        int n2 = input.getN(2);&lt;br /&gt;
        int n1 = input.getN(1);&lt;br /&gt;
        //Perform clipping operation on a single trace and write out.&lt;br /&gt;
        float[] data = new float[n1];&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                input.read(data);&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    if (data[k] &amp;gt; clip) data[k] = clip;&lt;br /&gt;
                    else if (data[k] &amp;lt; -clip) data[k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
                output.write(data);&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         output.setN(1,n1);&lt;br /&gt;
         output.setN(2,n2);&lt;br /&gt;
         output.setN(3,n3);&lt;br /&gt;
         input.close();&lt;br /&gt;
         output.close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are only three classes in the interface:&lt;br /&gt;
&lt;br /&gt;
1 -- RSF - The command line argument parser, and the initializer for the native interface.  An RSF object MUST be instantiated BEFORE instantiating an Input or Output object.&lt;br /&gt;
&lt;br /&gt;
2 -- Input - An object that provides read access to an RSF file.  &lt;br /&gt;
&lt;br /&gt;
3 -- Output - An object that provides write access to an RSF file.&lt;br /&gt;
&lt;br /&gt;
Additionally, the shared library (libjrsf.so or libjrsf.dll) must be included via the System.loadLibrary(&amp;quot;jrsf&amp;quot;); as the first command in the file.&lt;br /&gt;
&lt;br /&gt;
To compile on the command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $RSFROOT/lib Clip.java&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To include this as part of a SCons script (SConstruct):&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500 l1=1000&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;dat Clip.class&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s Clip clip=0.5&lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;))&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that we compile Clip.java using the SCons Java builder.  To execute the command, we have to locate the &amp;quot;java&amp;quot; command, which we do using WhereIs(&#039;java&#039;).  Then we execute the class name, and pass any command line arguments as usual.  The files are read from standard in for this program and written to standard out.  &lt;br /&gt;
&lt;br /&gt;
Please see the [[Library Reference]] for more details on the functions available in the SWIG API.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: Additional Java packages can included in SCons automatically by setting the CLASSPATH environment variable to point to the JAR files that they are contained in.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Mines JTK===&lt;br /&gt;
&#039;&#039;&#039;THIS INTERFACE IS DEPRECATED AND ONLY PROVIDED AS A REFERENCE.  THIS INTERFACE IS NO LONGER SUPPORTED AND WILL BE REMOVED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This interface may still be compiled by specifying the MINESJTK environment variable. &lt;br /&gt;
&lt;br /&gt;
The interface to Java is less full featured than others.  Presently, it only allows you to read RSF files with fewer than 4-dimensions into Java, and then export RSF files.  &#039;&#039;&#039;The Java interface does not support reading from standard in, or writing from standard out.  Therefore, the Java Interface does not support piping either.&#039;&#039;&#039; The Java interface at present treats all values as floats, and does not have support for complex numbers.  Java programs are not parsed for self-doc information like other programs are either.  Using javadoc may be a viable alternative to creating a parsing engine for Java programs.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, the JAR file rsf.jar will be added to your $RSFROOT/lib folder.  &lt;br /&gt;
&lt;br /&gt;
There are two ways to access the API:&lt;br /&gt;
&lt;br /&gt;
1 - From the command line:  point the classpath at BOTH compile and runtime to this location on the command line.&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
javac -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test.java &lt;br /&gt;
java -cp $MINESJTK:$RSFROOT/lib/rsf.jar:. Test arg1=... arg2=... arg3=...&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2 - From within a SConstruct script:  BOTH the path for the API ($RSFROOT/lib) and the path to the Mines JTK ($MINESJTK) are automatically added to the environment variable CLASSPATH and JAVACLASSPATH for executions made within an SConstruct.  Additionally, any additional classes that are already in the CLASSPATH environmental variable in the shell that you launch from will be added to your classpath.  This allows you to include additional libraries automatically within your Java programs.  The local directory (.) is also included in the CLASSPATH.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&lt;br /&gt;
# Compiles Clip.class&lt;br /&gt;
project.Java(&#039;.&#039;,&#039;Clip.java&#039;)&lt;br /&gt;
&lt;br /&gt;
Flow(&#039;dat&#039;,None,&#039;spike n1=1000 n2=100 n3=10 nsp=1 k1=500&#039;)&lt;br /&gt;
Flow(&#039;clipd&#039;,&#039;Clip.class dat&#039;,&lt;br /&gt;
    &#039;&#039;&#039;&lt;br /&gt;
    %s ${SOURCES[0].filebase} clip=0.5 &lt;br /&gt;
    in=${SOURCES[1]} out=$TARGET &lt;br /&gt;
    &#039;&#039;&#039; % WhereIs(&#039;java&#039;),stdin=0,stdout=-1)&lt;br /&gt;
Flow(&#039;test.attr&#039;,&#039;clipd&#039;,&#039;sfattr&#039;)&lt;br /&gt;
&lt;br /&gt;
End()&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface itself is fairly straightforward.  More details on the methods exposed by the API can be found at the [[Library_Reference#Java_API | Library Reference]].&lt;br /&gt;
&lt;br /&gt;
Data clipping, argument parsing, and IO example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Par;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
&lt;br /&gt;
/* A simple Java program to clip a dataset.&lt;br /&gt;
&lt;br /&gt;
Presently, there is no automatic self-documentation generation for use&lt;br /&gt;
with sfdoc.  Javadoc may be a better way to generate self-doc for Java&lt;br /&gt;
programs.&lt;br /&gt;
&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
public class Clip {&lt;br /&gt;
    public static void main(String[] args){&lt;br /&gt;
        // Initialize command line argument passing&lt;br /&gt;
         Par par = new Par(args);&lt;br /&gt;
         // Get the input file name.&lt;br /&gt;
         String input = par.getString(&amp;quot;in&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         // If the input file name is nothing, then quit!&lt;br /&gt;
         if (input.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find input file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
         //If the output file name is nothing, then quit!&lt;br /&gt;
         String output = par.getString(&amp;quot;out&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
         if (output.equals(&amp;quot;&amp;quot;)){&lt;br /&gt;
                System.out.println(&amp;quot;Did not find output file!&amp;quot;);&lt;br /&gt;
                System.exit(1);&lt;br /&gt;
         }&lt;br /&gt;
        // Get the value to clip to.&lt;br /&gt;
         float clip = par.getFloat(&amp;quot;clip&amp;quot;,0.0f);&lt;br /&gt;
        //Read our header file.&lt;br /&gt;
         Header header = Reader.readHeader(input);&lt;br /&gt;
        // Read our binary data.&lt;br /&gt;
         float[][][] data = Reader.readBinary3D(header);&lt;br /&gt;
        //Initialize our array values.&lt;br /&gt;
         int n3 = header.getN(3);&lt;br /&gt;
         int n2 = header.getN(2);&lt;br /&gt;
         int n1 = header.getN(1);&lt;br /&gt;
        //Perform clipping operation.&lt;br /&gt;
         for(int i = 0; i &amp;lt; n3; ++i){&lt;br /&gt;
            for(int j = 0; j &amp;lt; n2; ++j){&lt;br /&gt;
                for(int k = 0; k &amp;lt; n1; ++k){&lt;br /&gt;
                    float trace = data[i][j][k];&lt;br /&gt;
                    if (trace &amp;gt; clip) data[i][j][k] = clip;&lt;br /&gt;
                    else if (trace &amp;lt; -clip) data[i][j][k] = -clip;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
        //Write our data out, using the same header values to the file&lt;br /&gt;
        //located at: output.&lt;br /&gt;
         Writer.writeRSF(header,data,output);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to read a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;junk.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
How to write a file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
                &lt;br /&gt;
                Header header = Reader.readHeader(&amp;quot;test.rsf&amp;quot;); //To read the header file, just feed in the path relative to the execution directory&lt;br /&gt;
                System.out.println(header); //The header file will print out if you ask it to, this is good for debugging&lt;br /&gt;
&lt;br /&gt;
                float[][] data = Reader.readBinary2D(header); //Now I can manipulate my data&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;test2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to create a dataset from scratch from within Java, then you can create an array of data, modify the values, create a header, and then write it out to rsf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
import rsf.Header;&lt;br /&gt;
import rsf.Reader;&lt;br /&gt;
import rsf.Writer;&lt;br /&gt;
&lt;br /&gt;
public class Test {&lt;br /&gt;
      public static void main(String[] args){&lt;br /&gt;
&lt;br /&gt;
                int n1 = 20;&lt;br /&gt;
                int n2 = 40;&lt;br /&gt;
                float[][] data = new float[n2][n1]; &lt;br /&gt;
                //The order for dimensions is reversed, because RSF stores them as column-major arrays (see Python API).&lt;br /&gt;
&lt;br /&gt;
                //...Do something&lt;br /&gt;
&lt;br /&gt;
                Header header = new Header();&lt;br /&gt;
                header.setN(1,n1);&lt;br /&gt;
                /* We set the values using the proper RSF number for the dimension, instead of the Java array index.&lt;br /&gt;
                   Example:  RSF Dimension 1, corresponds to array index 0 in Java.&lt;br /&gt;
                             However, we set the values using index 1.  The mapping is handled behind the scenes.&lt;br /&gt;
                 */&lt;br /&gt;
                header.setN(2,n2); &lt;br /&gt;
                header.setDelta(1,0.0);&lt;br /&gt;
                header.setLabel(1,&amp;quot;time&amp;quot;);&lt;br /&gt;
                header.setUnits(1,&amp;quot;s&amp;quot;);&lt;br /&gt;
                Writer.writeRSF(header,data,&amp;quot;junk2.rsf&amp;quot;); //Write out my data!&lt;br /&gt;
       }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1971</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1971"/>
		<updated>2011-08-06T01:23:53Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Compilers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Compilers==&lt;br /&gt;
Madagascar has been built successfully with the following compilers, and possibly with others:&lt;br /&gt;
* gcc&lt;br /&gt;
* Intel (icc/ifort)&lt;br /&gt;
* open64&lt;br /&gt;
* clang&lt;br /&gt;
&lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS, Scientific Linux, openSUSE==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
Names of packages that are runtime dependencies are &#039;&#039;&#039;highlighted&#039;&#039;&#039; in the tables below (task under construction).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==OpenSolaris==&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;pkg&amp;lt;/tt&amp;gt; to install missing components such as X11 headers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
pfexec pkg install SUNWxorg-headers&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1970</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1970"/>
		<updated>2011-08-06T01:23:17Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Compilers==&lt;br /&gt;
Madagascar has been built successfully at least with the following compilers:&lt;br /&gt;
* gcc&lt;br /&gt;
* Intel (icc/ifort)&lt;br /&gt;
* open64&lt;br /&gt;
* clang&lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS, Scientific Linux, openSUSE==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
Names of packages that are runtime dependencies are &#039;&#039;&#039;highlighted&#039;&#039;&#039; in the tables below (task under construction).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==OpenSolaris==&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;pkg&amp;lt;/tt&amp;gt; to install missing components such as X11 headers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
pfexec pkg install SUNWxorg-headers&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Library_Reference&amp;diff=1955</id>
		<title>Library Reference</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Library_Reference&amp;diff=1955"/>
		<updated>2011-07-24T18:54:52Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Calling standalone madagascar programs from Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_2848987_XS.jpg|right|]]&lt;br /&gt;
If you are programming with Madagascar, please use the utilities described below instead of creating your own equivalents. The RSF library is written in C, and all facilities offered by it are available directly to the C API via inclusion of header files and linking with the library. Other APIs only have access to a limited set of functions from the library. The ultimate guide to what the libraries provide is the file &amp;lt;tt&amp;gt;RSFSRC/filt/lib/SConstruct&amp;lt;/tt&amp;gt;, which contains the instructions for building the RSF library in C and the interfaces to it for the various APIs.&lt;br /&gt;
=C API=&lt;br /&gt;
==Macros==&lt;br /&gt;
The following useful macros are accessible through the C and C++ APIs:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Functions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_ABS(a) || (a) &amp;gt;= 0  ? (a) : (-(a)) || Absolute value&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX(a,b) || (a) &amp;lt; (b) ? (b) : (a) || Maximum of two values  &lt;br /&gt;
|-&lt;br /&gt;
| SF_MIN(a,b) || (a) &amp;lt; (b) ? (a) : (b) || Minimum of two values&lt;br /&gt;
|-&lt;br /&gt;
| SF_SIG(a) || (a) &amp;gt;= 0  ?  1  :  -1  || Sign function&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|General constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOL || &#039;\014&#039; || End-of-line ASCII character&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOT || &#039;\004&#039; || End-of-transmission ASCII character  &lt;br /&gt;
|-&lt;br /&gt;
| SF_EPS || FLT_EPSILON || The smallest X of type float such that 1.0 + X != 1.0. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_HUGE || FLT_MAX || The largest finite representable value of type float. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX_DIM || 9 || Maximum number of dimensions in a RSF file&lt;br /&gt;
|-&lt;br /&gt;
| SF_PI || 3.141592653589793 || The number pi&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|SEG-Y-related constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_FORMAT || 24 || Byte position in SEG-Y binary reel header, where info on encoding of data samples is kept ([[Guide_to_madagascar_programs#SEG-Y_specific_parameters|format parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_NS || 20 || Byte position in SEG-Y binary reel header, where info on nr of samples in one trace is kept ([[Guide_to_madagascar_programs#Common_parameters|ns parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_DT || 16 || Byte position in SEG-Y binary reel header, where info on time sampling is kept&lt;br /&gt;
|-&lt;br /&gt;
| SF_EBCBYTES || 3200 || Bytes in the SEG-Y EBCDIC reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_BNYBYTES || 400 || Bytes in the SEG-Y binary reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_HDRBYTES || 240 || Bytes in each individual SEG-Y trace header&lt;br /&gt;
|-&lt;br /&gt;
| SF_NKEYS || 71 || Number of mandated header fields&lt;br /&gt;
|-&lt;br /&gt;
| SF_BHKEYS || 27 || Number of mandated binary fields&lt;br /&gt;
|}&lt;br /&gt;
These macros were found with: &amp;lt;bash&amp;gt;grep &#039;# define SF_&#039; $RSFROOT/include/rsf.h&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
See the [http://m8r.info/RSF/book/rsf/manual/manual_html/node8.html Data Types section of the Programming Reference Manual]&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
See the [http://www.reproducibility.org/RSF/book/rsf/manual/manual_html/ Programming Reference Manual].&lt;br /&gt;
&lt;br /&gt;
==Function wrappers==&lt;br /&gt;
These programs make the respective function callable from the command line, so that it can be used directly with files/other programs through &amp;quot;metaprograms&amp;quot; (shell/Python scripts). This allows the user to get the best of all worlds -- fast development in Python, all of Madagascar&#039;s visualization tools for debugging, and the speed of code written in C. This allows fast prototyping, followed by writing a production version in C calling the functions used.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Library function || Program&lt;br /&gt;
|-&lt;br /&gt;
| sf_filedims || [http://reproducibility.org/RSF/sffiledims.html filedims]&lt;br /&gt;
|-&lt;br /&gt;
| sf_leftsize || [http://reproducibility.org/RSF/sfleftsize.html leftsize]&lt;br /&gt;
|-&lt;br /&gt;
| sf_quantile || [http://reproducibility.org/RSF/sfquantile.html quantile]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=C++ API=&lt;br /&gt;
==Macros==&lt;br /&gt;
Same as for the C API.&lt;br /&gt;
&lt;br /&gt;
=Fortran 77 API=&lt;br /&gt;
=Fortran 90 API=&lt;br /&gt;
The interface is accessed by including a &amp;lt;tt&amp;gt;use rsf&amp;lt;/tt&amp;gt; statement in your program. The source code for the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module can be viewed  [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/api/f90/rsf.f90?view=markup in the repository]. A (&#039;&#039;&#039;G&#039;&#039;&#039;) means that the entity was featured in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to API]].&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_char&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_complex&amp;lt;/tt&amp;gt;=4&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_float&amp;lt;/tt&amp;gt;=3 (&#039;&#039;&#039;G&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_int&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_short&amp;lt;/tt&amp;gt;=5&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_uchar&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_set&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_cur&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_end&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
All procedures in Madagascar&#039;s F90 API act upon or take as input one of the following data types:&lt;br /&gt;
* &amp;lt;tt&amp;gt;axa&amp;lt;/tt&amp;gt;: Holds some info about a hypercube axis (integer::n; real::o,d)&lt;br /&gt;
* &amp;lt;tt&amp;gt;file&amp;lt;/tt&amp;gt;: Simply an interface to the &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; type described in the C library.&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;Result&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; || &#039;&#039;character&#039;&#039; &amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt; || Given a string &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; and a positive number &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, this function will return the concatenation of the string and the number converted to string (&amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt;). In practice, &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; will probably be &amp;quot;n&amp;quot;, &amp;quot;o&amp;quot;, &amp;quot;d&amp;quot;, &amp;quot;label&amp;quot; or &amp;quot;unit&amp;quot;, in preparation for writing to a header file. Default value for &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; is &amp;quot;n&amp;quot;. || Verbose string operations in F90 || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;dimension&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || Returns number of dimensions of already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;, and the dimension values in &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; nr_elements || Computes number of &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;-dimensional subcubes in file hypercube. When &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is absent, default is zero and the number of elements in file. || &amp;lt;tt&amp;gt;sf_filesize&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;. || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; || Reads the binary data type from the already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; constant should be then compared in the user-written code with one of the six type constants provided by the F90 interface || &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for reading and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;in&amp;quot;, which corresponds to the standard input stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for writing and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;out&amp;quot;, which corresponds to the standard output stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Subroutines==&lt;br /&gt;
Because subroutine names are preceded by a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement, it is easy to find occurrences of them being used by typing: &amp;lt;bash&amp;gt;grep &amp;quot;call subroutine_name&amp;quot; {filt,user}/*/*.f90 user/*/*/*.f90&amp;lt;/bash&amp;gt; in RSFSRC. &lt;br /&gt;
&lt;br /&gt;
Below, data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. The type &amp;lt;i&amp;gt;multi&amp;lt;/i&amp;gt; means that multiple data types can be used (subroutine is overloaded). In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_either&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || This subroutine looks for the real or integer variable &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; first in the history file, then in the parameter table. If it it is not found and &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, it assigns it to &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, otherwise it terminates the program. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || optional &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || If already-opened file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; is supplied, then it reads into &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; a parameter designated by &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; from a history file. Else, it reads it from the parameter table. If the parameter is not found and a &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, then that is used, else ends with failure. It can read from both history files and parameter tables the following types: integer, integer array, real. Strings can be read only from the history file, and not from the parameter table. Real arrays, logicals and logical arrays can be read only from the parameter table. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histstring&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloats&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbools&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;iaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Read axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; as axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; from the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;oaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag,&amp;lt;/tt&amp;gt; &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname,&amp;lt;/tt&amp;gt; &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Write axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; (i.e. its n, o, d) as axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;raxa&amp;lt;/tt&amp;gt; || &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || unformatted write to I/O unit nr. 0 (usually stdout, but system-dependent) of the contents of the &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; structure (n, o, d) || F90 write statement || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, the real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be read into it from an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, reads enough to fill the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be written to an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, writes to file the entire contents of the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;file_type&amp;lt;/tt&amp;gt; || Write a type for the binary data to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Data type constants are also provided by the F90 API. || &amp;lt;tt&amp;gt;sf_settype&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;to_par&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; || Writes &amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt; to already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Value can be integer, integer array, real or character. || &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putstring&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions from the C library==&lt;br /&gt;
Functions from the C library for which an interface has been defined at the end of &amp;lt;tt&amp;gt;RSFSRC/api/f90/fortran.c&amp;lt;/tt&amp;gt; can be called directly from Madagascar F90 programs. The programmer must know, however, that &#039;&#039;&#039;an argument type mismatch will result in a silent failure, with no informative errors.&#039;&#039;&#039; There may be other sources of problems as well. Caution therefore must be advised when calling these functions. The reason for these issues is that [http://people.scs.fsu.edu/~burkardt/f_src/mixed/mixed.html if a FORTRAN90 routine needs to pass a scalar parameter to a C routine, there is no standard way to ensure that a value is passed rather than an address]. The success rate of calling C from Fortran [http://w3.pppl.gov/~dmccune/papers-reports/linux_f90.txt is compiler-dependent] and [http://www.cs.sandia.gov/Zoltan/ug_html/ug_fortran.html special types may have to be defined for portability]. If you do have to call a C function from F90, follow the examples of the functions below. Use the C library reference to find argument and output types. A C-to-F90 data type dictionary follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C ||! style=&amp;quot;background:#ffdead;&amp;quot; | F90&lt;br /&gt;
|-&lt;br /&gt;
| RSFFILE || type(file)&lt;br /&gt;
|-&lt;br /&gt;
| INT || integer&lt;br /&gt;
|-&lt;br /&gt;
| OFFSETT || integer(kind=OFFKIND)&lt;br /&gt;
|}&lt;br /&gt;
===Void-output functions callable as subroutines===&lt;br /&gt;
These can be treated as subroutines, and accessed with a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement. Follow &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) (&#039;&#039;&#039;&#039;&#039;Can it also be called in subroutines if we want to isolate I/O operations there?&#039;&#039;&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Non-void-output functions===&lt;br /&gt;
It is a good idea to declare in your program the function output type and use the keyword &amp;lt;tt&amp;gt;external&amp;lt;/tt&amp;gt;, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;real, external :: sf_dosomething&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternately, you may define a F90 &amp;lt;tt&amp;gt;interface&amp;lt;/tt&amp;gt; block for the procedure(s). &lt;br /&gt;
&lt;br /&gt;
Several examples can be found in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/rsf.f90&amp;lt;/tt&amp;gt;, but they are not enumerated here because F90 wrappers exist for them and they should be used instead of the direct calls to the C library functions.&lt;br /&gt;
&lt;br /&gt;
=Matlab API=&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means: &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#MATLAB_interface|Guide to the Matlab API]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;new_file_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;old_file_name&amp;lt;/tt&amp;gt;, or &#039;&#039;double (column vector)&#039;&#039; &#039;&#039;&#039;in&#039;&#039;&#039; &amp;lt;tt&amp;gt;new_file_cube_dims&amp;lt;/tt&amp;gt;  || Writes to disk RSF header of native_float hypercube of desired dimensions. Takes as input the name of the new file and either the name of another file with a cube of the same size, or a column with cube dimensions || &amp;lt;tt&amp;gt;sf_fileflush&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_setformat&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt; || Arg1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || Returns a 9-element vector [n1, n2, ... n9] with the dimensions of the hypercube as described in the RSF header &#039;&#039;&#039;filename&#039;&#039;&#039;. Missing dimensions are given the value 1 || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt;  Arg 3: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_type&amp;lt;/tt&amp;gt;: i[nt], l[ogical], f[loat];&amp;lt;br /&amp;gt;  Arg 4: &#039;&#039;double (scalar)&#039;&#039; &amp;lt;tt&amp;gt;default_val&amp;lt;/tt&amp;gt;  ||  Returns a scalar parameter read from a RSF header || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;  || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Reads &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Input data should be of SF_FLOAT, SF_INT or SF_COMPLEX type. The &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; parameter is a way to indicate if the data is read from the same file as before or from a newly opened file. If &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; is not given, the data will be read from the beginning of the file. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_intread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Writes &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Data to be written can be integer, float, double or complex. It will get cast to RSF&#039;s native_float or native_complex encoding. || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Octave API=&lt;br /&gt;
&lt;br /&gt;
=Java API=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;There are two APIs available for Java.  New programs should be written to use the SWIG API.  The Mines JTK API is provided here only for reference for those who may still be using it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== SWIG API ==&lt;br /&gt;
The SWIG API includes three classes.  The methods that each class exposes are as follows:&lt;br /&gt;
&lt;br /&gt;
=== RSF ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public RSF(String[] args);                           // Constructor, pass the command line arguments&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Input(String name);                           // Constructor, pass a filename.  &amp;quot;in&amp;quot; defaults to stdin&lt;br /&gt;
public int getN(int index);                          // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public float getDelta(int index);                    // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public float getOrigin(int index);                   // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public String getLabel(int index);                   // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public String getUnit(int index);                    // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                 // Close the file.&lt;br /&gt;
public void read(float[] array);                     // Read data from the open RSF file into the given array.  Reads the length of the array only.&lt;br /&gt;
public void read(float[][] array);                   // The following methods all read data from the RSF file in the given shape of the array.&lt;br /&gt;
public void read(float[][][] array);&lt;br /&gt;
public void read(float[][][][] array);&lt;br /&gt;
public void read(float[][][][][] array);&lt;br /&gt;
public void read(float[][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Output(String name);                           // Constructor, pass a filename.  &amp;quot;out&amp;quot; points to standard out.&lt;br /&gt;
public void setN(int index, int n);                   // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public void setDelta(int index, float delta);         // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public void setOrigin(int index, float origin);       // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public void setLabel(int index, String label);        // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void setUnit(int index, String unit);          // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                  // Close the file.&lt;br /&gt;
public void write(float[] array);                     // Writes data to the RSF file from the given array.  Writes the shape of the array only.&lt;br /&gt;
public void write(float[][] array);                   // The following methods all write data using the given shape of the array.&lt;br /&gt;
public void write(float[][][] array);&lt;br /&gt;
public void write(float[][][][] array);&lt;br /&gt;
public void write(float[][][][][] array);&lt;br /&gt;
public void write(float[][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional notes:&lt;br /&gt;
&lt;br /&gt;
Java does not support complex numbers by default.  To use complex numbers, you must convert complex valued RSF files to floating point numbers using sfdd .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MINES JTK API == &lt;br /&gt;
&#039;&#039;&#039; THIS API IS DEPRECATED.  PLEASE DEVELOP YOUR PROGRAMS TO BE COMPATIBLE WITH THE SWIG API.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following methods are exposed directly at this time:&lt;br /&gt;
&lt;br /&gt;
==Par Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Header Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public void setN(int dim, int n);             // Used to set the number of elements in a dimension. For dimension 1, use an index value of 1.&lt;br /&gt;
public int getN(int dim);&lt;br /&gt;
public void setDelta(int dim, float delta);   // Used to set the delta for a dimension. For dimension 1, use an index value of 1, not 0.&lt;br /&gt;
public float getDelta(int dim);&lt;br /&gt;
public void setOrigin(int dim, float origin); // Used to set the origin for a dimension.  &lt;br /&gt;
public float getOrigin(int dim);&lt;br /&gt;
public void setLabel(int dim, String label);  // Sets the label for a dimension.&lt;br /&gt;
public String getLabel(int dim);&lt;br /&gt;
public void setUnit(int dim, String unit);    // Sets the unit for a dimension.&lt;br /&gt;
public String getUnit(int dim);&lt;br /&gt;
public void setFormat(String format);         // Sets the output format information, has no effect on how Java treats the data.&lt;br /&gt;
public String getFormat();&lt;br /&gt;
public void setPath(String path);             /* Sets the location of the binary file that corresponds to this header file. &lt;br /&gt;
                                                 Not used for writing information to an RSF file. */&lt;br /&gt;
public String getPath();&lt;br /&gt;
public void setName(String name);             /* Change the file name that this header corresponds to. When writing this info to an RSF file, &lt;br /&gt;
                                                 the API automatically will determine the binary file that goes along with this filename. */&lt;br /&gt;
public String getName();&lt;br /&gt;
public String toString();                     // Can be used to print out information about the header file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Writer Class==&lt;br /&gt;
&lt;br /&gt;
When writing out RSF files, the header file is output in the same directory as the java program was executed. The binary file is placed according to the DATAPATH environment variable. &amp;lt;tt&amp;gt;saveName&amp;lt;/tt&amp;gt; is the filename that you want to save your header to. Writing to standard out is not supported. All files must be saved via a name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[] data, String saveName);     // Writes a 1D array to an RSF Header and binary file&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][] data, String saveName);   // Writes a 2D array to an RSF header and binary file.&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][][] data, String saveName); // Writes a 3D array to an RSF header and binary file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reader Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static Header         readHeader(String headerFileName); // Used to parse the RSF Header file for information.&lt;br /&gt;
public static float[]        readBinary(RSFHeader header);      // Reads the RSF binary data file into a single array.&lt;br /&gt;
public static float[][]      readBinary2D(RSFHeader header);    // Reads the RSF binary data file into a 2D array.&lt;br /&gt;
public static float[][][]    readBinary3D(RSFHeader header);    // Reads the RSF binary data file into a 3D array.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python API=&lt;br /&gt;
&lt;br /&gt;
To use the python api, you need to import the rsf package via: &amp;lt;tt&amp;gt;import rsf.api&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Madagascar now has automatic documentation, currently with Epydoc, and more to come. The information in the table below will be merged into it.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The rsf package has the following members:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+ Overview of the Python RSF API&lt;br /&gt;
! Class !! Use !! Constructor !! Example !! Available Methods&lt;br /&gt;
|-&lt;br /&gt;
|File&lt;br /&gt;
|-&lt;br /&gt;
|Filter&lt;br /&gt;
|-&lt;br /&gt;
|Movie&lt;br /&gt;
|-&lt;br /&gt;
|Input || Provides a basic way to read rsf files. || file = rsf.Input(name) || input = rsf.Input(&#039;&#039;name&#039;&#039;); n1 = input.int(&#039;n1&#039;) || read(data), data is a numpy array to be read into.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || close()&lt;br /&gt;
|-&lt;br /&gt;
| || || || || float(key, default=None), key is a string to be extracted, e.g. &#039;n1&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || int(key, default=None), key is a string to be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ints(key, num, default=None), key is a string, num is the number of ints.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || put(key, val), key is a string to set the value for, val is a numerical value (int or float).&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ... and more, type help(rsf.Input) on a python interactive session for more information.&lt;br /&gt;
|-&lt;br /&gt;
|Output || Provides a way to output numpy arrays to rsf files.  || file = rsf.Output(name) || output=rsf.Output(name); output.write(data)&lt;br /&gt;
|-&lt;br /&gt;
|OverUnder&lt;br /&gt;
|-&lt;br /&gt;
|Overlay&lt;br /&gt;
|-&lt;br /&gt;
|Par || Provides a method for accessing rsf parameters passed from the command line. || par = rsf.Par() || par = rsf.Par(); velname = par.string(&#039;vel&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|SideBySide&lt;br /&gt;
|-&lt;br /&gt;
|Temp&lt;br /&gt;
|-&lt;br /&gt;
|Vplot || View vplot graphics files from within python. || plot = rsf.Vplot(name) || plot = rsf.Vplot(name); plot.show()&lt;br /&gt;
|-&lt;br /&gt;
|Vppen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Calling standalone madagascar programs from Python=&lt;br /&gt;
On systems with recent versions of Python (at least 2.4), and with Numpy and Swig installed, use [http://www.reproducibility.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html the m8r module].&lt;br /&gt;
&lt;br /&gt;
On old systems where dependencies cannot be easily installed (i.e. industrial clusters), use the &amp;lt;tt&amp;gt;sf&amp;lt;/tt&amp;gt; module (i.e. &amp;lt;tt&amp;gt;import rsf.user.sf as sf&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=SCons custom methods=&lt;br /&gt;
==Custom builders==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;File implemented in&#039;&#039;&#039; || &#039;&#039;&#039;Function&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Include&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Header || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Place&amp;lt;/tt&amp;gt; ||  RSFSRC/framework/bldutil.py || Place || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Pycompile&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py ||Pycompile || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Docmerge&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Docmerge || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Other entities can be found in RSFSRC/framework/rsf/proj.py and tex.py&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Library_Reference&amp;diff=1954</id>
		<title>Library Reference</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Library_Reference&amp;diff=1954"/>
		<updated>2011-07-24T18:48:53Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Calling standalone madagascar programs from Python */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_2848987_XS.jpg|right|]]&lt;br /&gt;
If you are programming with Madagascar, please use the utilities described below instead of creating your own equivalents. The RSF library is written in C, and all facilities offered by it are available directly to the C API via inclusion of header files and linking with the library. Other APIs only have access to a limited set of functions from the library. The ultimate guide to what the libraries provide is the file &amp;lt;tt&amp;gt;RSFSRC/filt/lib/SConstruct&amp;lt;/tt&amp;gt;, which contains the instructions for building the RSF library in C and the interfaces to it for the various APIs.&lt;br /&gt;
=C API=&lt;br /&gt;
==Macros==&lt;br /&gt;
The following useful macros are accessible through the C and C++ APIs:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Functions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_ABS(a) || (a) &amp;gt;= 0  ? (a) : (-(a)) || Absolute value&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX(a,b) || (a) &amp;lt; (b) ? (b) : (a) || Maximum of two values  &lt;br /&gt;
|-&lt;br /&gt;
| SF_MIN(a,b) || (a) &amp;lt; (b) ? (a) : (b) || Minimum of two values&lt;br /&gt;
|-&lt;br /&gt;
| SF_SIG(a) || (a) &amp;gt;= 0  ?  1  :  -1  || Sign function&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|General constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOL || &#039;\014&#039; || End-of-line ASCII character&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOT || &#039;\004&#039; || End-of-transmission ASCII character  &lt;br /&gt;
|-&lt;br /&gt;
| SF_EPS || FLT_EPSILON || The smallest X of type float such that 1.0 + X != 1.0. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_HUGE || FLT_MAX || The largest finite representable value of type float. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX_DIM || 9 || Maximum number of dimensions in a RSF file&lt;br /&gt;
|-&lt;br /&gt;
| SF_PI || 3.141592653589793 || The number pi&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|SEG-Y-related constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_FORMAT || 24 || Byte position in SEG-Y binary reel header, where info on encoding of data samples is kept ([[Guide_to_madagascar_programs#SEG-Y_specific_parameters|format parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_NS || 20 || Byte position in SEG-Y binary reel header, where info on nr of samples in one trace is kept ([[Guide_to_madagascar_programs#Common_parameters|ns parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_DT || 16 || Byte position in SEG-Y binary reel header, where info on time sampling is kept&lt;br /&gt;
|-&lt;br /&gt;
| SF_EBCBYTES || 3200 || Bytes in the SEG-Y EBCDIC reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_BNYBYTES || 400 || Bytes in the SEG-Y binary reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_HDRBYTES || 240 || Bytes in each individual SEG-Y trace header&lt;br /&gt;
|-&lt;br /&gt;
| SF_NKEYS || 71 || Number of mandated header fields&lt;br /&gt;
|-&lt;br /&gt;
| SF_BHKEYS || 27 || Number of mandated binary fields&lt;br /&gt;
|}&lt;br /&gt;
These macros were found with: &amp;lt;bash&amp;gt;grep &#039;# define SF_&#039; $RSFROOT/include/rsf.h&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
See the [http://m8r.info/RSF/book/rsf/manual/manual_html/node8.html Data Types section of the Programming Reference Manual]&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
See the [http://www.reproducibility.org/RSF/book/rsf/manual/manual_html/ Programming Reference Manual].&lt;br /&gt;
&lt;br /&gt;
==Function wrappers==&lt;br /&gt;
These programs make the respective function callable from the command line, so that it can be used directly with files/other programs through &amp;quot;metaprograms&amp;quot; (shell/Python scripts). This allows the user to get the best of all worlds -- fast development in Python, all of Madagascar&#039;s visualization tools for debugging, and the speed of code written in C. This allows fast prototyping, followed by writing a production version in C calling the functions used.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Library function || Program&lt;br /&gt;
|-&lt;br /&gt;
| sf_filedims || [http://reproducibility.org/RSF/sffiledims.html filedims]&lt;br /&gt;
|-&lt;br /&gt;
| sf_leftsize || [http://reproducibility.org/RSF/sfleftsize.html leftsize]&lt;br /&gt;
|-&lt;br /&gt;
| sf_quantile || [http://reproducibility.org/RSF/sfquantile.html quantile]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=C++ API=&lt;br /&gt;
==Macros==&lt;br /&gt;
Same as for the C API.&lt;br /&gt;
&lt;br /&gt;
=Fortran 77 API=&lt;br /&gt;
=Fortran 90 API=&lt;br /&gt;
The interface is accessed by including a &amp;lt;tt&amp;gt;use rsf&amp;lt;/tt&amp;gt; statement in your program. The source code for the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module can be viewed  [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/api/f90/rsf.f90?view=markup in the repository]. A (&#039;&#039;&#039;G&#039;&#039;&#039;) means that the entity was featured in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to API]].&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_char&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_complex&amp;lt;/tt&amp;gt;=4&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_float&amp;lt;/tt&amp;gt;=3 (&#039;&#039;&#039;G&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_int&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_short&amp;lt;/tt&amp;gt;=5&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_uchar&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_set&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_cur&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_end&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
All procedures in Madagascar&#039;s F90 API act upon or take as input one of the following data types:&lt;br /&gt;
* &amp;lt;tt&amp;gt;axa&amp;lt;/tt&amp;gt;: Holds some info about a hypercube axis (integer::n; real::o,d)&lt;br /&gt;
* &amp;lt;tt&amp;gt;file&amp;lt;/tt&amp;gt;: Simply an interface to the &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; type described in the C library.&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;Result&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; || &#039;&#039;character&#039;&#039; &amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt; || Given a string &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; and a positive number &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, this function will return the concatenation of the string and the number converted to string (&amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt;). In practice, &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; will probably be &amp;quot;n&amp;quot;, &amp;quot;o&amp;quot;, &amp;quot;d&amp;quot;, &amp;quot;label&amp;quot; or &amp;quot;unit&amp;quot;, in preparation for writing to a header file. Default value for &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; is &amp;quot;n&amp;quot;. || Verbose string operations in F90 || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;dimension&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || Returns number of dimensions of already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;, and the dimension values in &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; nr_elements || Computes number of &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;-dimensional subcubes in file hypercube. When &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is absent, default is zero and the number of elements in file. || &amp;lt;tt&amp;gt;sf_filesize&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;. || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; || Reads the binary data type from the already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; constant should be then compared in the user-written code with one of the six type constants provided by the F90 interface || &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for reading and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;in&amp;quot;, which corresponds to the standard input stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for writing and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;out&amp;quot;, which corresponds to the standard output stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Subroutines==&lt;br /&gt;
Because subroutine names are preceded by a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement, it is easy to find occurrences of them being used by typing: &amp;lt;bash&amp;gt;grep &amp;quot;call subroutine_name&amp;quot; {filt,user}/*/*.f90 user/*/*/*.f90&amp;lt;/bash&amp;gt; in RSFSRC. &lt;br /&gt;
&lt;br /&gt;
Below, data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. The type &amp;lt;i&amp;gt;multi&amp;lt;/i&amp;gt; means that multiple data types can be used (subroutine is overloaded). In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_either&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || This subroutine looks for the real or integer variable &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; first in the history file, then in the parameter table. If it it is not found and &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, it assigns it to &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, otherwise it terminates the program. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || optional &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || If already-opened file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; is supplied, then it reads into &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; a parameter designated by &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; from a history file. Else, it reads it from the parameter table. If the parameter is not found and a &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, then that is used, else ends with failure. It can read from both history files and parameter tables the following types: integer, integer array, real. Strings can be read only from the history file, and not from the parameter table. Real arrays, logicals and logical arrays can be read only from the parameter table. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histstring&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloats&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbools&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;iaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Read axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; as axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; from the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;oaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag,&amp;lt;/tt&amp;gt; &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname,&amp;lt;/tt&amp;gt; &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Write axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; (i.e. its n, o, d) as axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;raxa&amp;lt;/tt&amp;gt; || &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || unformatted write to I/O unit nr. 0 (usually stdout, but system-dependent) of the contents of the &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; structure (n, o, d) || F90 write statement || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, the real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be read into it from an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, reads enough to fill the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be written to an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, writes to file the entire contents of the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;file_type&amp;lt;/tt&amp;gt; || Write a type for the binary data to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Data type constants are also provided by the F90 API. || &amp;lt;tt&amp;gt;sf_settype&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;to_par&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; || Writes &amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt; to already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Value can be integer, integer array, real or character. || &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putstring&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions from the C library==&lt;br /&gt;
Functions from the C library for which an interface has been defined at the end of &amp;lt;tt&amp;gt;RSFSRC/api/f90/fortran.c&amp;lt;/tt&amp;gt; can be called directly from Madagascar F90 programs. The programmer must know, however, that &#039;&#039;&#039;an argument type mismatch will result in a silent failure, with no informative errors.&#039;&#039;&#039; There may be other sources of problems as well. Caution therefore must be advised when calling these functions. The reason for these issues is that [http://people.scs.fsu.edu/~burkardt/f_src/mixed/mixed.html if a FORTRAN90 routine needs to pass a scalar parameter to a C routine, there is no standard way to ensure that a value is passed rather than an address]. The success rate of calling C from Fortran [http://w3.pppl.gov/~dmccune/papers-reports/linux_f90.txt is compiler-dependent] and [http://www.cs.sandia.gov/Zoltan/ug_html/ug_fortran.html special types may have to be defined for portability]. If you do have to call a C function from F90, follow the examples of the functions below. Use the C library reference to find argument and output types. A C-to-F90 data type dictionary follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C ||! style=&amp;quot;background:#ffdead;&amp;quot; | F90&lt;br /&gt;
|-&lt;br /&gt;
| RSFFILE || type(file)&lt;br /&gt;
|-&lt;br /&gt;
| INT || integer&lt;br /&gt;
|-&lt;br /&gt;
| OFFSETT || integer(kind=OFFKIND)&lt;br /&gt;
|}&lt;br /&gt;
===Void-output functions callable as subroutines===&lt;br /&gt;
These can be treated as subroutines, and accessed with a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement. Follow &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) (&#039;&#039;&#039;&#039;&#039;Can it also be called in subroutines if we want to isolate I/O operations there?&#039;&#039;&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Non-void-output functions===&lt;br /&gt;
It is a good idea to declare in your program the function output type and use the keyword &amp;lt;tt&amp;gt;external&amp;lt;/tt&amp;gt;, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;real, external :: sf_dosomething&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternately, you may define a F90 &amp;lt;tt&amp;gt;interface&amp;lt;/tt&amp;gt; block for the procedure(s). &lt;br /&gt;
&lt;br /&gt;
Several examples can be found in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/rsf.f90&amp;lt;/tt&amp;gt;, but they are not enumerated here because F90 wrappers exist for them and they should be used instead of the direct calls to the C library functions.&lt;br /&gt;
&lt;br /&gt;
=Matlab API=&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means: &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#MATLAB_interface|Guide to the Matlab API]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;new_file_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;old_file_name&amp;lt;/tt&amp;gt;, or &#039;&#039;double (column vector)&#039;&#039; &#039;&#039;&#039;in&#039;&#039;&#039; &amp;lt;tt&amp;gt;new_file_cube_dims&amp;lt;/tt&amp;gt;  || Writes to disk RSF header of native_float hypercube of desired dimensions. Takes as input the name of the new file and either the name of another file with a cube of the same size, or a column with cube dimensions || &amp;lt;tt&amp;gt;sf_fileflush&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_setformat&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt; || Arg1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || Returns a 9-element vector [n1, n2, ... n9] with the dimensions of the hypercube as described in the RSF header &#039;&#039;&#039;filename&#039;&#039;&#039;. Missing dimensions are given the value 1 || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt;  Arg 3: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_type&amp;lt;/tt&amp;gt;: i[nt], l[ogical], f[loat];&amp;lt;br /&amp;gt;  Arg 4: &#039;&#039;double (scalar)&#039;&#039; &amp;lt;tt&amp;gt;default_val&amp;lt;/tt&amp;gt;  ||  Returns a scalar parameter read from a RSF header || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;  || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Reads &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Input data should be of SF_FLOAT, SF_INT or SF_COMPLEX type. The &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; parameter is a way to indicate if the data is read from the same file as before or from a newly opened file. If &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; is not given, the data will be read from the beginning of the file. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_intread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Writes &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Data to be written can be integer, float, double or complex. It will get cast to RSF&#039;s native_float or native_complex encoding. || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Octave API=&lt;br /&gt;
&lt;br /&gt;
=Java API=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;There are two APIs available for Java.  New programs should be written to use the SWIG API.  The Mines JTK API is provided here only for reference for those who may still be using it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== SWIG API ==&lt;br /&gt;
The SWIG API includes three classes.  The methods that each class exposes are as follows:&lt;br /&gt;
&lt;br /&gt;
=== RSF ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public RSF(String[] args);                           // Constructor, pass the command line arguments&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Input(String name);                           // Constructor, pass a filename.  &amp;quot;in&amp;quot; defaults to stdin&lt;br /&gt;
public int getN(int index);                          // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public float getDelta(int index);                    // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public float getOrigin(int index);                   // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public String getLabel(int index);                   // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public String getUnit(int index);                    // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                 // Close the file.&lt;br /&gt;
public void read(float[] array);                     // Read data from the open RSF file into the given array.  Reads the length of the array only.&lt;br /&gt;
public void read(float[][] array);                   // The following methods all read data from the RSF file in the given shape of the array.&lt;br /&gt;
public void read(float[][][] array);&lt;br /&gt;
public void read(float[][][][] array);&lt;br /&gt;
public void read(float[][][][][] array);&lt;br /&gt;
public void read(float[][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Output(String name);                           // Constructor, pass a filename.  &amp;quot;out&amp;quot; points to standard out.&lt;br /&gt;
public void setN(int index, int n);                   // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public void setDelta(int index, float delta);         // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public void setOrigin(int index, float origin);       // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public void setLabel(int index, String label);        // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void setUnit(int index, String unit);          // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                  // Close the file.&lt;br /&gt;
public void write(float[] array);                     // Writes data to the RSF file from the given array.  Writes the shape of the array only.&lt;br /&gt;
public void write(float[][] array);                   // The following methods all write data using the given shape of the array.&lt;br /&gt;
public void write(float[][][] array);&lt;br /&gt;
public void write(float[][][][] array);&lt;br /&gt;
public void write(float[][][][][] array);&lt;br /&gt;
public void write(float[][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional notes:&lt;br /&gt;
&lt;br /&gt;
Java does not support complex numbers by default.  To use complex numbers, you must convert complex valued RSF files to floating point numbers using sfdd .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MINES JTK API == &lt;br /&gt;
&#039;&#039;&#039; THIS API IS DEPRECATED.  PLEASE DEVELOP YOUR PROGRAMS TO BE COMPATIBLE WITH THE SWIG API.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following methods are exposed directly at this time:&lt;br /&gt;
&lt;br /&gt;
==Par Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Header Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public void setN(int dim, int n);             // Used to set the number of elements in a dimension. For dimension 1, use an index value of 1.&lt;br /&gt;
public int getN(int dim);&lt;br /&gt;
public void setDelta(int dim, float delta);   // Used to set the delta for a dimension. For dimension 1, use an index value of 1, not 0.&lt;br /&gt;
public float getDelta(int dim);&lt;br /&gt;
public void setOrigin(int dim, float origin); // Used to set the origin for a dimension.  &lt;br /&gt;
public float getOrigin(int dim);&lt;br /&gt;
public void setLabel(int dim, String label);  // Sets the label for a dimension.&lt;br /&gt;
public String getLabel(int dim);&lt;br /&gt;
public void setUnit(int dim, String unit);    // Sets the unit for a dimension.&lt;br /&gt;
public String getUnit(int dim);&lt;br /&gt;
public void setFormat(String format);         // Sets the output format information, has no effect on how Java treats the data.&lt;br /&gt;
public String getFormat();&lt;br /&gt;
public void setPath(String path);             /* Sets the location of the binary file that corresponds to this header file. &lt;br /&gt;
                                                 Not used for writing information to an RSF file. */&lt;br /&gt;
public String getPath();&lt;br /&gt;
public void setName(String name);             /* Change the file name that this header corresponds to. When writing this info to an RSF file, &lt;br /&gt;
                                                 the API automatically will determine the binary file that goes along with this filename. */&lt;br /&gt;
public String getName();&lt;br /&gt;
public String toString();                     // Can be used to print out information about the header file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Writer Class==&lt;br /&gt;
&lt;br /&gt;
When writing out RSF files, the header file is output in the same directory as the java program was executed. The binary file is placed according to the DATAPATH environment variable. &amp;lt;tt&amp;gt;saveName&amp;lt;/tt&amp;gt; is the filename that you want to save your header to. Writing to standard out is not supported. All files must be saved via a name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[] data, String saveName);     // Writes a 1D array to an RSF Header and binary file&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][] data, String saveName);   // Writes a 2D array to an RSF header and binary file.&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][][] data, String saveName); // Writes a 3D array to an RSF header and binary file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reader Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static Header         readHeader(String headerFileName); // Used to parse the RSF Header file for information.&lt;br /&gt;
public static float[]        readBinary(RSFHeader header);      // Reads the RSF binary data file into a single array.&lt;br /&gt;
public static float[][]      readBinary2D(RSFHeader header);    // Reads the RSF binary data file into a 2D array.&lt;br /&gt;
public static float[][][]    readBinary3D(RSFHeader header);    // Reads the RSF binary data file into a 3D array.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python API=&lt;br /&gt;
&lt;br /&gt;
To use the python api, you need to import the rsf package via: &amp;lt;tt&amp;gt;import rsf.api&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Madagascar now has automatic documentation, currently with Epydoc, and more to come. The information in the table below will be merged into it.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The rsf package has the following members:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+ Overview of the Python RSF API&lt;br /&gt;
! Class !! Use !! Constructor !! Example !! Available Methods&lt;br /&gt;
|-&lt;br /&gt;
|File&lt;br /&gt;
|-&lt;br /&gt;
|Filter&lt;br /&gt;
|-&lt;br /&gt;
|Movie&lt;br /&gt;
|-&lt;br /&gt;
|Input || Provides a basic way to read rsf files. || file = rsf.Input(name) || input = rsf.Input(&#039;&#039;name&#039;&#039;); n1 = input.int(&#039;n1&#039;) || read(data), data is a numpy array to be read into.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || close()&lt;br /&gt;
|-&lt;br /&gt;
| || || || || float(key, default=None), key is a string to be extracted, e.g. &#039;n1&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || int(key, default=None), key is a string to be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ints(key, num, default=None), key is a string, num is the number of ints.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || put(key, val), key is a string to set the value for, val is a numerical value (int or float).&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ... and more, type help(rsf.Input) on a python interactive session for more information.&lt;br /&gt;
|-&lt;br /&gt;
|Output || Provides a way to output numpy arrays to rsf files.  || file = rsf.Output(name) || output=rsf.Output(name); output.write(data)&lt;br /&gt;
|-&lt;br /&gt;
|OverUnder&lt;br /&gt;
|-&lt;br /&gt;
|Overlay&lt;br /&gt;
|-&lt;br /&gt;
|Par || Provides a method for accessing rsf parameters passed from the command line. || par = rsf.Par() || par = rsf.Par(); velname = par.string(&#039;vel&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|SideBySide&lt;br /&gt;
|-&lt;br /&gt;
|Temp&lt;br /&gt;
|-&lt;br /&gt;
|Vplot || View vplot graphics files from within python. || plot = rsf.Vplot(name) || plot = rsf.Vplot(name); plot.show()&lt;br /&gt;
|-&lt;br /&gt;
|Vppen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Calling standalone madagascar programs from Python=&lt;br /&gt;
On systems with recent versions of Python (at least 2.4), and with Numpy and Swig installed, use [http://www.reproducibility.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html the m8r module].&lt;br /&gt;
&lt;br /&gt;
On old systems where dependencies cannot be easily installed (i.e. industrial clusters), the &amp;lt;tt&amp;gt;sf&amp;lt;/tt&amp;gt; module (i.e. &amp;lt;tt&amp;gt;import rsf.user.sf as sf&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=SCons custom methods=&lt;br /&gt;
==Custom builders==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;File implemented in&#039;&#039;&#039; || &#039;&#039;&#039;Function&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Include&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Header || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Place&amp;lt;/tt&amp;gt; ||  RSFSRC/framework/bldutil.py || Place || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Pycompile&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py ||Pycompile || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Docmerge&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Docmerge || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Other entities can be found in RSFSRC/framework/rsf/proj.py and tex.py&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Library_Reference&amp;diff=1953</id>
		<title>Library Reference</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Library_Reference&amp;diff=1953"/>
		<updated>2011-07-24T18:48:39Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* SCons custom methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_2848987_XS.jpg|right|]]&lt;br /&gt;
If you are programming with Madagascar, please use the utilities described below instead of creating your own equivalents. The RSF library is written in C, and all facilities offered by it are available directly to the C API via inclusion of header files and linking with the library. Other APIs only have access to a limited set of functions from the library. The ultimate guide to what the libraries provide is the file &amp;lt;tt&amp;gt;RSFSRC/filt/lib/SConstruct&amp;lt;/tt&amp;gt;, which contains the instructions for building the RSF library in C and the interfaces to it for the various APIs.&lt;br /&gt;
=C API=&lt;br /&gt;
==Macros==&lt;br /&gt;
The following useful macros are accessible through the C and C++ APIs:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Functions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_ABS(a) || (a) &amp;gt;= 0  ? (a) : (-(a)) || Absolute value&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX(a,b) || (a) &amp;lt; (b) ? (b) : (a) || Maximum of two values  &lt;br /&gt;
|-&lt;br /&gt;
| SF_MIN(a,b) || (a) &amp;lt; (b) ? (a) : (b) || Minimum of two values&lt;br /&gt;
|-&lt;br /&gt;
| SF_SIG(a) || (a) &amp;gt;= 0  ?  1  :  -1  || Sign function&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|General constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOL || &#039;\014&#039; || End-of-line ASCII character&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOT || &#039;\004&#039; || End-of-transmission ASCII character  &lt;br /&gt;
|-&lt;br /&gt;
| SF_EPS || FLT_EPSILON || The smallest X of type float such that 1.0 + X != 1.0. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_HUGE || FLT_MAX || The largest finite representable value of type float. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX_DIM || 9 || Maximum number of dimensions in a RSF file&lt;br /&gt;
|-&lt;br /&gt;
| SF_PI || 3.141592653589793 || The number pi&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|SEG-Y-related constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_FORMAT || 24 || Byte position in SEG-Y binary reel header, where info on encoding of data samples is kept ([[Guide_to_madagascar_programs#SEG-Y_specific_parameters|format parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_NS || 20 || Byte position in SEG-Y binary reel header, where info on nr of samples in one trace is kept ([[Guide_to_madagascar_programs#Common_parameters|ns parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_DT || 16 || Byte position in SEG-Y binary reel header, where info on time sampling is kept&lt;br /&gt;
|-&lt;br /&gt;
| SF_EBCBYTES || 3200 || Bytes in the SEG-Y EBCDIC reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_BNYBYTES || 400 || Bytes in the SEG-Y binary reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_HDRBYTES || 240 || Bytes in each individual SEG-Y trace header&lt;br /&gt;
|-&lt;br /&gt;
| SF_NKEYS || 71 || Number of mandated header fields&lt;br /&gt;
|-&lt;br /&gt;
| SF_BHKEYS || 27 || Number of mandated binary fields&lt;br /&gt;
|}&lt;br /&gt;
These macros were found with: &amp;lt;bash&amp;gt;grep &#039;# define SF_&#039; $RSFROOT/include/rsf.h&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
See the [http://m8r.info/RSF/book/rsf/manual/manual_html/node8.html Data Types section of the Programming Reference Manual]&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
See the [http://www.reproducibility.org/RSF/book/rsf/manual/manual_html/ Programming Reference Manual].&lt;br /&gt;
&lt;br /&gt;
==Function wrappers==&lt;br /&gt;
These programs make the respective function callable from the command line, so that it can be used directly with files/other programs through &amp;quot;metaprograms&amp;quot; (shell/Python scripts). This allows the user to get the best of all worlds -- fast development in Python, all of Madagascar&#039;s visualization tools for debugging, and the speed of code written in C. This allows fast prototyping, followed by writing a production version in C calling the functions used.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Library function || Program&lt;br /&gt;
|-&lt;br /&gt;
| sf_filedims || [http://reproducibility.org/RSF/sffiledims.html filedims]&lt;br /&gt;
|-&lt;br /&gt;
| sf_leftsize || [http://reproducibility.org/RSF/sfleftsize.html leftsize]&lt;br /&gt;
|-&lt;br /&gt;
| sf_quantile || [http://reproducibility.org/RSF/sfquantile.html quantile]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=C++ API=&lt;br /&gt;
==Macros==&lt;br /&gt;
Same as for the C API.&lt;br /&gt;
&lt;br /&gt;
=Fortran 77 API=&lt;br /&gt;
=Fortran 90 API=&lt;br /&gt;
The interface is accessed by including a &amp;lt;tt&amp;gt;use rsf&amp;lt;/tt&amp;gt; statement in your program. The source code for the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module can be viewed  [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/api/f90/rsf.f90?view=markup in the repository]. A (&#039;&#039;&#039;G&#039;&#039;&#039;) means that the entity was featured in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to API]].&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_char&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_complex&amp;lt;/tt&amp;gt;=4&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_float&amp;lt;/tt&amp;gt;=3 (&#039;&#039;&#039;G&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_int&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_short&amp;lt;/tt&amp;gt;=5&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_uchar&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_set&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_cur&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_end&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
All procedures in Madagascar&#039;s F90 API act upon or take as input one of the following data types:&lt;br /&gt;
* &amp;lt;tt&amp;gt;axa&amp;lt;/tt&amp;gt;: Holds some info about a hypercube axis (integer::n; real::o,d)&lt;br /&gt;
* &amp;lt;tt&amp;gt;file&amp;lt;/tt&amp;gt;: Simply an interface to the &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; type described in the C library.&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;Result&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; || &#039;&#039;character&#039;&#039; &amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt; || Given a string &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; and a positive number &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, this function will return the concatenation of the string and the number converted to string (&amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt;). In practice, &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; will probably be &amp;quot;n&amp;quot;, &amp;quot;o&amp;quot;, &amp;quot;d&amp;quot;, &amp;quot;label&amp;quot; or &amp;quot;unit&amp;quot;, in preparation for writing to a header file. Default value for &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; is &amp;quot;n&amp;quot;. || Verbose string operations in F90 || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;dimension&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || Returns number of dimensions of already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;, and the dimension values in &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; nr_elements || Computes number of &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;-dimensional subcubes in file hypercube. When &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is absent, default is zero and the number of elements in file. || &amp;lt;tt&amp;gt;sf_filesize&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;. || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; || Reads the binary data type from the already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; constant should be then compared in the user-written code with one of the six type constants provided by the F90 interface || &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for reading and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;in&amp;quot;, which corresponds to the standard input stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for writing and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;out&amp;quot;, which corresponds to the standard output stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Subroutines==&lt;br /&gt;
Because subroutine names are preceded by a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement, it is easy to find occurrences of them being used by typing: &amp;lt;bash&amp;gt;grep &amp;quot;call subroutine_name&amp;quot; {filt,user}/*/*.f90 user/*/*/*.f90&amp;lt;/bash&amp;gt; in RSFSRC. &lt;br /&gt;
&lt;br /&gt;
Below, data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. The type &amp;lt;i&amp;gt;multi&amp;lt;/i&amp;gt; means that multiple data types can be used (subroutine is overloaded). In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_either&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || This subroutine looks for the real or integer variable &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; first in the history file, then in the parameter table. If it it is not found and &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, it assigns it to &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, otherwise it terminates the program. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || optional &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || If already-opened file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; is supplied, then it reads into &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; a parameter designated by &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; from a history file. Else, it reads it from the parameter table. If the parameter is not found and a &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, then that is used, else ends with failure. It can read from both history files and parameter tables the following types: integer, integer array, real. Strings can be read only from the history file, and not from the parameter table. Real arrays, logicals and logical arrays can be read only from the parameter table. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histstring&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloats&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbools&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;iaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Read axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; as axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; from the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;oaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag,&amp;lt;/tt&amp;gt; &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname,&amp;lt;/tt&amp;gt; &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Write axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; (i.e. its n, o, d) as axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;raxa&amp;lt;/tt&amp;gt; || &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || unformatted write to I/O unit nr. 0 (usually stdout, but system-dependent) of the contents of the &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; structure (n, o, d) || F90 write statement || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, the real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be read into it from an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, reads enough to fill the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be written to an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, writes to file the entire contents of the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;file_type&amp;lt;/tt&amp;gt; || Write a type for the binary data to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Data type constants are also provided by the F90 API. || &amp;lt;tt&amp;gt;sf_settype&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;to_par&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; || Writes &amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt; to already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Value can be integer, integer array, real or character. || &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putstring&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions from the C library==&lt;br /&gt;
Functions from the C library for which an interface has been defined at the end of &amp;lt;tt&amp;gt;RSFSRC/api/f90/fortran.c&amp;lt;/tt&amp;gt; can be called directly from Madagascar F90 programs. The programmer must know, however, that &#039;&#039;&#039;an argument type mismatch will result in a silent failure, with no informative errors.&#039;&#039;&#039; There may be other sources of problems as well. Caution therefore must be advised when calling these functions. The reason for these issues is that [http://people.scs.fsu.edu/~burkardt/f_src/mixed/mixed.html if a FORTRAN90 routine needs to pass a scalar parameter to a C routine, there is no standard way to ensure that a value is passed rather than an address]. The success rate of calling C from Fortran [http://w3.pppl.gov/~dmccune/papers-reports/linux_f90.txt is compiler-dependent] and [http://www.cs.sandia.gov/Zoltan/ug_html/ug_fortran.html special types may have to be defined for portability]. If you do have to call a C function from F90, follow the examples of the functions below. Use the C library reference to find argument and output types. A C-to-F90 data type dictionary follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C ||! style=&amp;quot;background:#ffdead;&amp;quot; | F90&lt;br /&gt;
|-&lt;br /&gt;
| RSFFILE || type(file)&lt;br /&gt;
|-&lt;br /&gt;
| INT || integer&lt;br /&gt;
|-&lt;br /&gt;
| OFFSETT || integer(kind=OFFKIND)&lt;br /&gt;
|}&lt;br /&gt;
===Void-output functions callable as subroutines===&lt;br /&gt;
These can be treated as subroutines, and accessed with a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement. Follow &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) (&#039;&#039;&#039;&#039;&#039;Can it also be called in subroutines if we want to isolate I/O operations there?&#039;&#039;&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Non-void-output functions===&lt;br /&gt;
It is a good idea to declare in your program the function output type and use the keyword &amp;lt;tt&amp;gt;external&amp;lt;/tt&amp;gt;, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;real, external :: sf_dosomething&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternately, you may define a F90 &amp;lt;tt&amp;gt;interface&amp;lt;/tt&amp;gt; block for the procedure(s). &lt;br /&gt;
&lt;br /&gt;
Several examples can be found in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/rsf.f90&amp;lt;/tt&amp;gt;, but they are not enumerated here because F90 wrappers exist for them and they should be used instead of the direct calls to the C library functions.&lt;br /&gt;
&lt;br /&gt;
=Matlab API=&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means: &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#MATLAB_interface|Guide to the Matlab API]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;new_file_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;old_file_name&amp;lt;/tt&amp;gt;, or &#039;&#039;double (column vector)&#039;&#039; &#039;&#039;&#039;in&#039;&#039;&#039; &amp;lt;tt&amp;gt;new_file_cube_dims&amp;lt;/tt&amp;gt;  || Writes to disk RSF header of native_float hypercube of desired dimensions. Takes as input the name of the new file and either the name of another file with a cube of the same size, or a column with cube dimensions || &amp;lt;tt&amp;gt;sf_fileflush&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_setformat&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt; || Arg1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || Returns a 9-element vector [n1, n2, ... n9] with the dimensions of the hypercube as described in the RSF header &#039;&#039;&#039;filename&#039;&#039;&#039;. Missing dimensions are given the value 1 || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt;  Arg 3: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_type&amp;lt;/tt&amp;gt;: i[nt], l[ogical], f[loat];&amp;lt;br /&amp;gt;  Arg 4: &#039;&#039;double (scalar)&#039;&#039; &amp;lt;tt&amp;gt;default_val&amp;lt;/tt&amp;gt;  ||  Returns a scalar parameter read from a RSF header || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;  || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Reads &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Input data should be of SF_FLOAT, SF_INT or SF_COMPLEX type. The &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; parameter is a way to indicate if the data is read from the same file as before or from a newly opened file. If &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; is not given, the data will be read from the beginning of the file. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_intread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Writes &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Data to be written can be integer, float, double or complex. It will get cast to RSF&#039;s native_float or native_complex encoding. || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Octave API=&lt;br /&gt;
&lt;br /&gt;
=Java API=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;There are two APIs available for Java.  New programs should be written to use the SWIG API.  The Mines JTK API is provided here only for reference for those who may still be using it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== SWIG API ==&lt;br /&gt;
The SWIG API includes three classes.  The methods that each class exposes are as follows:&lt;br /&gt;
&lt;br /&gt;
=== RSF ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public RSF(String[] args);                           // Constructor, pass the command line arguments&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Input(String name);                           // Constructor, pass a filename.  &amp;quot;in&amp;quot; defaults to stdin&lt;br /&gt;
public int getN(int index);                          // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public float getDelta(int index);                    // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public float getOrigin(int index);                   // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public String getLabel(int index);                   // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public String getUnit(int index);                    // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                 // Close the file.&lt;br /&gt;
public void read(float[] array);                     // Read data from the open RSF file into the given array.  Reads the length of the array only.&lt;br /&gt;
public void read(float[][] array);                   // The following methods all read data from the RSF file in the given shape of the array.&lt;br /&gt;
public void read(float[][][] array);&lt;br /&gt;
public void read(float[][][][] array);&lt;br /&gt;
public void read(float[][][][][] array);&lt;br /&gt;
public void read(float[][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Output(String name);                           // Constructor, pass a filename.  &amp;quot;out&amp;quot; points to standard out.&lt;br /&gt;
public void setN(int index, int n);                   // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public void setDelta(int index, float delta);         // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public void setOrigin(int index, float origin);       // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public void setLabel(int index, String label);        // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void setUnit(int index, String unit);          // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                  // Close the file.&lt;br /&gt;
public void write(float[] array);                     // Writes data to the RSF file from the given array.  Writes the shape of the array only.&lt;br /&gt;
public void write(float[][] array);                   // The following methods all write data using the given shape of the array.&lt;br /&gt;
public void write(float[][][] array);&lt;br /&gt;
public void write(float[][][][] array);&lt;br /&gt;
public void write(float[][][][][] array);&lt;br /&gt;
public void write(float[][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional notes:&lt;br /&gt;
&lt;br /&gt;
Java does not support complex numbers by default.  To use complex numbers, you must convert complex valued RSF files to floating point numbers using sfdd .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MINES JTK API == &lt;br /&gt;
&#039;&#039;&#039; THIS API IS DEPRECATED.  PLEASE DEVELOP YOUR PROGRAMS TO BE COMPATIBLE WITH THE SWIG API.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following methods are exposed directly at this time:&lt;br /&gt;
&lt;br /&gt;
==Par Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Header Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public void setN(int dim, int n);             // Used to set the number of elements in a dimension. For dimension 1, use an index value of 1.&lt;br /&gt;
public int getN(int dim);&lt;br /&gt;
public void setDelta(int dim, float delta);   // Used to set the delta for a dimension. For dimension 1, use an index value of 1, not 0.&lt;br /&gt;
public float getDelta(int dim);&lt;br /&gt;
public void setOrigin(int dim, float origin); // Used to set the origin for a dimension.  &lt;br /&gt;
public float getOrigin(int dim);&lt;br /&gt;
public void setLabel(int dim, String label);  // Sets the label for a dimension.&lt;br /&gt;
public String getLabel(int dim);&lt;br /&gt;
public void setUnit(int dim, String unit);    // Sets the unit for a dimension.&lt;br /&gt;
public String getUnit(int dim);&lt;br /&gt;
public void setFormat(String format);         // Sets the output format information, has no effect on how Java treats the data.&lt;br /&gt;
public String getFormat();&lt;br /&gt;
public void setPath(String path);             /* Sets the location of the binary file that corresponds to this header file. &lt;br /&gt;
                                                 Not used for writing information to an RSF file. */&lt;br /&gt;
public String getPath();&lt;br /&gt;
public void setName(String name);             /* Change the file name that this header corresponds to. When writing this info to an RSF file, &lt;br /&gt;
                                                 the API automatically will determine the binary file that goes along with this filename. */&lt;br /&gt;
public String getName();&lt;br /&gt;
public String toString();                     // Can be used to print out information about the header file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Writer Class==&lt;br /&gt;
&lt;br /&gt;
When writing out RSF files, the header file is output in the same directory as the java program was executed. The binary file is placed according to the DATAPATH environment variable. &amp;lt;tt&amp;gt;saveName&amp;lt;/tt&amp;gt; is the filename that you want to save your header to. Writing to standard out is not supported. All files must be saved via a name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[] data, String saveName);     // Writes a 1D array to an RSF Header and binary file&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][] data, String saveName);   // Writes a 2D array to an RSF header and binary file.&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][][] data, String saveName); // Writes a 3D array to an RSF header and binary file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reader Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static Header         readHeader(String headerFileName); // Used to parse the RSF Header file for information.&lt;br /&gt;
public static float[]        readBinary(RSFHeader header);      // Reads the RSF binary data file into a single array.&lt;br /&gt;
public static float[][]      readBinary2D(RSFHeader header);    // Reads the RSF binary data file into a 2D array.&lt;br /&gt;
public static float[][][]    readBinary3D(RSFHeader header);    // Reads the RSF binary data file into a 3D array.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python API=&lt;br /&gt;
&lt;br /&gt;
To use the python api, you need to import the rsf package via: &amp;lt;tt&amp;gt;import rsf.api&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Madagascar now has automatic documentation, currently with Epydoc, and more to come. The information in the table below will be merged into it.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The rsf package has the following members:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+ Overview of the Python RSF API&lt;br /&gt;
! Class !! Use !! Constructor !! Example !! Available Methods&lt;br /&gt;
|-&lt;br /&gt;
|File&lt;br /&gt;
|-&lt;br /&gt;
|Filter&lt;br /&gt;
|-&lt;br /&gt;
|Movie&lt;br /&gt;
|-&lt;br /&gt;
|Input || Provides a basic way to read rsf files. || file = rsf.Input(name) || input = rsf.Input(&#039;&#039;name&#039;&#039;); n1 = input.int(&#039;n1&#039;) || read(data), data is a numpy array to be read into.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || close()&lt;br /&gt;
|-&lt;br /&gt;
| || || || || float(key, default=None), key is a string to be extracted, e.g. &#039;n1&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || int(key, default=None), key is a string to be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ints(key, num, default=None), key is a string, num is the number of ints.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || put(key, val), key is a string to set the value for, val is a numerical value (int or float).&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ... and more, type help(rsf.Input) on a python interactive session for more information.&lt;br /&gt;
|-&lt;br /&gt;
|Output || Provides a way to output numpy arrays to rsf files.  || file = rsf.Output(name) || output=rsf.Output(name); output.write(data)&lt;br /&gt;
|-&lt;br /&gt;
|OverUnder&lt;br /&gt;
|-&lt;br /&gt;
|Overlay&lt;br /&gt;
|-&lt;br /&gt;
|Par || Provides a method for accessing rsf parameters passed from the command line. || par = rsf.Par() || par = rsf.Par(); velname = par.string(&#039;vel&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|SideBySide&lt;br /&gt;
|-&lt;br /&gt;
|Temp&lt;br /&gt;
|-&lt;br /&gt;
|Vplot || View vplot graphics files from within python. || plot = rsf.Vplot(name) || plot = rsf.Vplot(name); plot.show()&lt;br /&gt;
|-&lt;br /&gt;
|Vppen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Calling standalone madagascar programs from Python=&lt;br /&gt;
On systems with recent versions of Python (at least 2.4), and with Numpy and Swig installed, use [http://www.reproducibility.org/rsflog/index.php?/archives/264-Running-Madagascar-in-an-interactive-console.html the m8r module.&lt;br /&gt;
&lt;br /&gt;
On old systems where dependencies cannot be easily installed (i.e. industrial clusters), the &amp;lt;tt&amp;gt;sf&amp;lt;/tt&amp;gt; module (i.e. &amp;lt;tt&amp;gt;import rsf.user.sf as sf&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=SCons custom methods=&lt;br /&gt;
==Custom builders==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;File implemented in&#039;&#039;&#039; || &#039;&#039;&#039;Function&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Include&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Header || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Place&amp;lt;/tt&amp;gt; ||  RSFSRC/framework/bldutil.py || Place || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Pycompile&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py ||Pycompile || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Docmerge&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Docmerge || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Other entities can be found in RSFSRC/framework/rsf/proj.py and tex.py&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Library_Reference&amp;diff=1952</id>
		<title>Library Reference</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Library_Reference&amp;diff=1952"/>
		<updated>2011-07-24T18:39:04Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Python API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_2848987_XS.jpg|right|]]&lt;br /&gt;
If you are programming with Madagascar, please use the utilities described below instead of creating your own equivalents. The RSF library is written in C, and all facilities offered by it are available directly to the C API via inclusion of header files and linking with the library. Other APIs only have access to a limited set of functions from the library. The ultimate guide to what the libraries provide is the file &amp;lt;tt&amp;gt;RSFSRC/filt/lib/SConstruct&amp;lt;/tt&amp;gt;, which contains the instructions for building the RSF library in C and the interfaces to it for the various APIs.&lt;br /&gt;
=C API=&lt;br /&gt;
==Macros==&lt;br /&gt;
The following useful macros are accessible through the C and C++ APIs:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Functions&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_ABS(a) || (a) &amp;gt;= 0  ? (a) : (-(a)) || Absolute value&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX(a,b) || (a) &amp;lt; (b) ? (b) : (a) || Maximum of two values  &lt;br /&gt;
|-&lt;br /&gt;
| SF_MIN(a,b) || (a) &amp;lt; (b) ? (a) : (b) || Minimum of two values&lt;br /&gt;
|-&lt;br /&gt;
| SF_SIG(a) || (a) &amp;gt;= 0  ?  1  :  -1  || Sign function&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|General constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOL || &#039;\014&#039; || End-of-line ASCII character&lt;br /&gt;
|-&lt;br /&gt;
| SF_EOT || &#039;\004&#039; || End-of-transmission ASCII character  &lt;br /&gt;
|-&lt;br /&gt;
| SF_EPS || FLT_EPSILON || The smallest X of type float such that 1.0 + X != 1.0. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_HUGE || FLT_MAX || The largest finite representable value of type float. From &amp;lt;tt&amp;gt;float.h&amp;lt;/tt&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| SF_MAX_DIM || 9 || Maximum number of dimensions in a RSF file&lt;br /&gt;
|-&lt;br /&gt;
| SF_PI || 3.141592653589793 || The number pi&lt;br /&gt;
|}&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|SEG-Y-related constants&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Value&#039;&#039;&#039; || &#039;&#039;&#039;Meaning&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_FORMAT || 24 || Byte position in SEG-Y binary reel header, where info on encoding of data samples is kept ([[Guide_to_madagascar_programs#SEG-Y_specific_parameters|format parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_NS || 20 || Byte position in SEG-Y binary reel header, where info on nr of samples in one trace is kept ([[Guide_to_madagascar_programs#Common_parameters|ns parameter in sfsegyread]])&lt;br /&gt;
|-&lt;br /&gt;
| SF_SEGY_DT || 16 || Byte position in SEG-Y binary reel header, where info on time sampling is kept&lt;br /&gt;
|-&lt;br /&gt;
| SF_EBCBYTES || 3200 || Bytes in the SEG-Y EBCDIC reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_BNYBYTES || 400 || Bytes in the SEG-Y binary reel header&lt;br /&gt;
|-&lt;br /&gt;
| SF_HDRBYTES || 240 || Bytes in each individual SEG-Y trace header&lt;br /&gt;
|-&lt;br /&gt;
| SF_NKEYS || 71 || Number of mandated header fields&lt;br /&gt;
|-&lt;br /&gt;
| SF_BHKEYS || 27 || Number of mandated binary fields&lt;br /&gt;
|}&lt;br /&gt;
These macros were found with: &amp;lt;bash&amp;gt;grep &#039;# define SF_&#039; $RSFROOT/include/rsf.h&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
See the [http://m8r.info/RSF/book/rsf/manual/manual_html/node8.html Data Types section of the Programming Reference Manual]&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
See the [http://www.reproducibility.org/RSF/book/rsf/manual/manual_html/ Programming Reference Manual].&lt;br /&gt;
&lt;br /&gt;
==Function wrappers==&lt;br /&gt;
These programs make the respective function callable from the command line, so that it can be used directly with files/other programs through &amp;quot;metaprograms&amp;quot; (shell/Python scripts). This allows the user to get the best of all worlds -- fast development in Python, all of Madagascar&#039;s visualization tools for debugging, and the speed of code written in C. This allows fast prototyping, followed by writing a production version in C calling the functions used.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Library function || Program&lt;br /&gt;
|-&lt;br /&gt;
| sf_filedims || [http://reproducibility.org/RSF/sffiledims.html filedims]&lt;br /&gt;
|-&lt;br /&gt;
| sf_leftsize || [http://reproducibility.org/RSF/sfleftsize.html leftsize]&lt;br /&gt;
|-&lt;br /&gt;
| sf_quantile || [http://reproducibility.org/RSF/sfquantile.html quantile]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=C++ API=&lt;br /&gt;
==Macros==&lt;br /&gt;
Same as for the C API.&lt;br /&gt;
&lt;br /&gt;
=Fortran 77 API=&lt;br /&gt;
=Fortran 90 API=&lt;br /&gt;
The interface is accessed by including a &amp;lt;tt&amp;gt;use rsf&amp;lt;/tt&amp;gt; statement in your program. The source code for the &amp;lt;tt&amp;gt;rsf&amp;lt;/tt&amp;gt; module can be viewed  [http://rsf.svn.sourceforge.net/viewvc/rsf/trunk/api/f90/rsf.f90?view=markup in the repository]. A (&#039;&#039;&#039;G&#039;&#039;&#039;) means that the entity was featured in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to API]].&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_char&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_complex&amp;lt;/tt&amp;gt;=4&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_float&amp;lt;/tt&amp;gt;=3 (&#039;&#039;&#039;G&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_int&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_short&amp;lt;/tt&amp;gt;=5&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_uchar&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
&lt;br /&gt;
For use with &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;:&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_set&amp;lt;/tt&amp;gt;=0&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_cur&amp;lt;/tt&amp;gt;=1&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek_end&amp;lt;/tt&amp;gt;=2&lt;br /&gt;
&lt;br /&gt;
==Data types==&lt;br /&gt;
All procedures in Madagascar&#039;s F90 API act upon or take as input one of the following data types:&lt;br /&gt;
* &amp;lt;tt&amp;gt;axa&amp;lt;/tt&amp;gt;: Holds some info about a hypercube axis (integer::n; real::o,d)&lt;br /&gt;
* &amp;lt;tt&amp;gt;file&amp;lt;/tt&amp;gt;: Simply an interface to the &amp;lt;tt&amp;gt;sf_file&amp;lt;/tt&amp;gt; type described in the C library.&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;Result&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; || &#039;&#039;character&#039;&#039; &amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt; || Given a string &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; and a positive number &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, this function will return the concatenation of the string and the number converted to string (&amp;lt;tt&amp;gt;mystringi&amp;lt;/tt&amp;gt;). In practice, &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; will probably be &amp;quot;n&amp;quot;, &amp;quot;o&amp;quot;, &amp;quot;d&amp;quot;, &amp;quot;label&amp;quot; or &amp;quot;unit&amp;quot;, in preparation for writing to a header file. Default value for &amp;lt;tt&amp;gt;mystring&amp;lt;/tt&amp;gt; is &amp;quot;n&amp;quot;. || Verbose string operations in F90 || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;dimension&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || Returns number of dimensions of already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;, and the dimension values in &amp;lt;tt&amp;gt;dims&amp;lt;/tt&amp;gt; || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;filesize&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; nr_elements || Computes number of &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt;-dimensional subcubes in file hypercube. When &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is absent, default is zero and the number of elements in file. || &amp;lt;tt&amp;gt;sf_filesize&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_leftsize&amp;lt;/tt&amp;gt;. || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;gettype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || &#039;&#039;integer&#039;&#039; &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; || Reads the binary data type from the already-open file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; constant should be then compared in the user-written code with one of the six type constants provided by the F90 interface || &amp;lt;tt&amp;gt;sf_gettype&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_input&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for reading and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;in&amp;quot;, which corresponds to the standard input stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_output&amp;lt;/tt&amp;gt; || optional &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Opens &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; for writing and returns file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. The default is &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;=&amp;quot;out&amp;quot;, which corresponds to the standard output stream || &amp;lt;tt&amp;gt;sf_input&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Subroutines==&lt;br /&gt;
Because subroutine names are preceded by a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement, it is easy to find occurrences of them being used by typing: &amp;lt;bash&amp;gt;grep &amp;quot;call subroutine_name&amp;quot; {filt,user}/*/*.f90 user/*/*/*.f90&amp;lt;/bash&amp;gt; in RSFSRC. &lt;br /&gt;
&lt;br /&gt;
Below, data types are indicated in &#039;&#039;italics&#039;&#039; and intent in &#039;&#039;&#039;&#039;&#039;bold italics&#039;&#039;&#039;&#039;&#039;. The type &amp;lt;i&amp;gt;multi&amp;lt;/i&amp;gt; means that multiple data types can be used (subroutine is overloaded). In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#Fortran-90_interface|Guide to the F90 API]]?&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_either&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || This subroutine looks for the real or integer variable &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; first in the history file, then in the parameter table. If it it is not found and &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, it assigns it to &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, otherwise it terminates the program. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || optional &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, optional &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; || If already-opened file handle &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; is supplied, then it reads into &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; a parameter designated by &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; from a history file. Else, it reads it from the parameter table. If the parameter is not found and a &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is present, then that is used, else ends with failure. It can read from both history files and parameter tables the following types: integer, integer array, real. Strings can be read only from the history file, and not from the parameter table. Real arrays, logicals and logical arrays can be read only from the parameter table. || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histstring&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getfloats&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_getbools&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;iaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Read axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; as axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; from the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;oaxa&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag,&amp;lt;/tt&amp;gt; &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname,&amp;lt;/tt&amp;gt; &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; || Write axis &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; (i.e. its n, o, d) as axis with number &amp;lt;tt&amp;gt;axisnr&amp;lt;/tt&amp;gt; to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt; || Multiple calls to F90 API&#039;s &amp;lt;tt&amp;gt;from_par&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;raxa&amp;lt;/tt&amp;gt; || &#039;&#039;axa&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; || unformatted write to I/O unit nr. 0 (usually stdout, but system-dependent) of the contents of the &amp;lt;tt&amp;gt;axisname&amp;lt;/tt&amp;gt; structure (n, o, d) || F90 write statement || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;out&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, the real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be read into it from an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, reads enough to fill the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt;, optional &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; || If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is specified, real or complex &amp;lt;tt&amp;gt;array&amp;lt;/tt&amp;gt; must be 1-D and &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; elements will be written to an already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;n&amp;lt;/tt&amp;gt; is not specified, writes to file the entire contents of the array, and the array can be 1-D, 2-D, 3-D, 4-D or 5-D || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;settype&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;integer&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;file_type&amp;lt;/tt&amp;gt; || Write a type for the binary data to the already-open file header indicated by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Data type constants are also provided by the F90 API. || &amp;lt;tt&amp;gt;sf_settype&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;to_par&amp;lt;/tt&amp;gt; || &#039;&#039;file&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;, &#039;&#039;character&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt;, &#039;&#039;multi&#039;&#039; &#039;&#039;&#039;&#039;&#039;in&#039;&#039;&#039;&#039;&#039; &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; || Writes &amp;lt;tt&amp;gt;name=value&amp;lt;/tt&amp;gt; to already-opened file specified by &amp;lt;tt&amp;gt;tag&amp;lt;/tt&amp;gt;. Value can be integer, integer array, real or character. || &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putints&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putfloat&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_putstring&amp;lt;/tt&amp;gt; || N&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions from the C library==&lt;br /&gt;
Functions from the C library for which an interface has been defined at the end of &amp;lt;tt&amp;gt;RSFSRC/api/f90/fortran.c&amp;lt;/tt&amp;gt; can be called directly from Madagascar F90 programs. The programmer must know, however, that &#039;&#039;&#039;an argument type mismatch will result in a silent failure, with no informative errors.&#039;&#039;&#039; There may be other sources of problems as well. Caution therefore must be advised when calling these functions. The reason for these issues is that [http://people.scs.fsu.edu/~burkardt/f_src/mixed/mixed.html if a FORTRAN90 routine needs to pass a scalar parameter to a C routine, there is no standard way to ensure that a value is passed rather than an address]. The success rate of calling C from Fortran [http://w3.pppl.gov/~dmccune/papers-reports/linux_f90.txt is compiler-dependent] and [http://www.cs.sandia.gov/Zoltan/ug_html/ug_fortran.html special types may have to be defined for portability]. If you do have to call a C function from F90, follow the examples of the functions below. Use the C library reference to find argument and output types. A C-to-F90 data type dictionary follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C ||! style=&amp;quot;background:#ffdead;&amp;quot; | F90&lt;br /&gt;
|-&lt;br /&gt;
| RSFFILE || type(file)&lt;br /&gt;
|-&lt;br /&gt;
| INT || integer&lt;br /&gt;
|-&lt;br /&gt;
| OFFSETT || integer(kind=OFFKIND)&lt;br /&gt;
|}&lt;br /&gt;
===Void-output functions callable as subroutines===&lt;br /&gt;
These can be treated as subroutines, and accessed with a &amp;lt;tt&amp;gt;call&amp;lt;/tt&amp;gt; statement. Follow &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_error&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) &lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_init&amp;lt;/tt&amp;gt; (&#039;&#039;&#039;G&#039;&#039;&#039;) (&#039;&#039;&#039;&#039;&#039;Can it also be called in subroutines if we want to isolate I/O operations there?&#039;&#039;&#039;&#039;&#039;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;sf_seek&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Non-void-output functions===&lt;br /&gt;
It is a good idea to declare in your program the function output type and use the keyword &amp;lt;tt&amp;gt;external&amp;lt;/tt&amp;gt;, i.e.:&lt;br /&gt;
&amp;lt;pre&amp;gt;real, external :: sf_dosomething&amp;lt;/pre&amp;gt;&lt;br /&gt;
Alternately, you may define a F90 &amp;lt;tt&amp;gt;interface&amp;lt;/tt&amp;gt; block for the procedure(s). &lt;br /&gt;
&lt;br /&gt;
Several examples can be found in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/rsf.f90&amp;lt;/tt&amp;gt;, but they are not enumerated here because F90 wrappers exist for them and they should be used instead of the direct calls to the C library functions.&lt;br /&gt;
&lt;br /&gt;
=Matlab API=&lt;br /&gt;
Data types are indicated in &#039;&#039;italics&#039;&#039;. In the &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; column, procedure names with no other description belong to the C library. The &#039;&#039;&#039;G?&#039;&#039;&#039; heading means: &amp;quot;Demo-ed in the [[Guide_to_madagascar_API#MATLAB_interface|Guide to the Matlab API]]?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Arguments&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039; || &#039;&#039;&#039;Wrapper for&#039;&#039;&#039; || &#039;&#039;&#039;G?&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_create&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;new_file_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;old_file_name&amp;lt;/tt&amp;gt;, or &#039;&#039;double (column vector)&#039;&#039; &#039;&#039;&#039;in&#039;&#039;&#039; &amp;lt;tt&amp;gt;new_file_cube_dims&amp;lt;/tt&amp;gt;  || Writes to disk RSF header of native_float hypercube of desired dimensions. Takes as input the name of the new file and either the name of another file with a cube of the same size, or a column with cube dimensions || &amp;lt;tt&amp;gt;sf_fileflush&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;sf_putint&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sf_setformat&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_dim&amp;lt;/tt&amp;gt; || Arg1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt; || Returns a 9-element vector [n1, n2, ... n9] with the dimensions of the hypercube as described in the RSF header &#039;&#039;&#039;filename&#039;&#039;&#039;. Missing dimensions are given the value 1 || &amp;lt;tt&amp;gt;sf_filedims&amp;lt;/tt&amp;gt; || Y&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_par&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_name&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt;  Arg 3: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;par_type&amp;lt;/tt&amp;gt;: i[nt], l[ogical], f[loat];&amp;lt;br /&amp;gt;  Arg 4: &#039;&#039;double (scalar)&#039;&#039; &amp;lt;tt&amp;gt;default_val&amp;lt;/tt&amp;gt;  ||  Returns a scalar parameter read from a RSF header || &amp;lt;tt&amp;gt;sf_histint&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histbool&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_histfloat&amp;lt;/tt&amp;gt;  || N&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_read&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Reads &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Input data should be of SF_FLOAT, SF_INT or SF_COMPLEX type. The &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; parameter is a way to indicate if the data is read from the same file as before or from a newly opened file. If &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt; is not given, the data will be read from the beginning of the file. || &amp;lt;tt&amp;gt;sf_floatread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_intread&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexread&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;rsf_write&amp;lt;/tt&amp;gt; || Arg 1: &#039;&#039;double&#039;&#039; &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 2: &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;;&amp;lt;br /&amp;gt; Arg 3 (optional): &#039;&#039;string (row vector)&#039;&#039; &amp;lt;tt&amp;gt;same&amp;lt;/tt&amp;gt;. If Arg 3 is given, value should be &amp;quot;same&amp;quot; || Writes &amp;lt;tt&amp;gt;data_array&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. Data to be written can be integer, float, double or complex. It will get cast to RSF&#039;s native_float or native_complex encoding. || &amp;lt;tt&amp;gt;sf_floatwrite&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;sf_complexwrite&amp;lt;/tt&amp;gt; || Y &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Octave API=&lt;br /&gt;
&lt;br /&gt;
=Java API=&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;There are two APIs available for Java.  New programs should be written to use the SWIG API.  The Mines JTK API is provided here only for reference for those who may still be using it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== SWIG API ==&lt;br /&gt;
The SWIG API includes three classes.  The methods that each class exposes are as follows:&lt;br /&gt;
&lt;br /&gt;
=== RSF ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public RSF(String[] args);                           // Constructor, pass the command line arguments&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Input(String name);                           // Constructor, pass a filename.  &amp;quot;in&amp;quot; defaults to stdin&lt;br /&gt;
public int getN(int index);                          // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public float getDelta(int index);                    // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public float getOrigin(int index);                   // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public String getLabel(int index);                   // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public String getUnit(int index);                    // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                 // Close the file.&lt;br /&gt;
public void read(float[] array);                     // Read data from the open RSF file into the given array.  Reads the length of the array only.&lt;br /&gt;
public void read(float[][] array);                   // The following methods all read data from the RSF file in the given shape of the array.&lt;br /&gt;
public void read(float[][][] array);&lt;br /&gt;
public void read(float[][][][] array);&lt;br /&gt;
public void read(float[][][][][] array);&lt;br /&gt;
public void read(float[][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][] array);&lt;br /&gt;
public void read(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public Output(String name);                           // Constructor, pass a filename.  &amp;quot;out&amp;quot; points to standard out.&lt;br /&gt;
public void setN(int index, int n);                   // Gets the number of elements in the file for that index.  Counting starts at 1. Returns 1 if not found.&lt;br /&gt;
public void setDelta(int index, float delta);         // Gets the delta for that index. Returns 0.0 if not found.&lt;br /&gt;
public void setOrigin(int index, float origin);       // Gets the origin for that file. Returns 0.0 if not found.  &lt;br /&gt;
public void setLabel(int index, String label);        // Gets the label name for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void setUnit(int index, String unit);          // Gets the unit for the index.  Returns &amp;quot;&amp;quot; if not found.&lt;br /&gt;
public void close();                                  // Close the file.&lt;br /&gt;
public void write(float[] array);                     // Writes data to the RSF file from the given array.  Writes the shape of the array only.&lt;br /&gt;
public void write(float[][] array);                   // The following methods all write data using the given shape of the array.&lt;br /&gt;
public void write(float[][][] array);&lt;br /&gt;
public void write(float[][][][] array);&lt;br /&gt;
public void write(float[][][][][] array);&lt;br /&gt;
public void write(float[][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][] array);&lt;br /&gt;
public void write(float[][][][][][][][][] array);&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional notes:&lt;br /&gt;
&lt;br /&gt;
Java does not support complex numbers by default.  To use complex numbers, you must convert complex valued RSF files to floating point numbers using sfdd .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MINES JTK API == &lt;br /&gt;
&#039;&#039;&#039; THIS API IS DEPRECATED.  PLEASE DEVELOP YOUR PROGRAMS TO BE COMPATIBLE WITH THE SWIG API.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following methods are exposed directly at this time:&lt;br /&gt;
&lt;br /&gt;
==Par Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public float getFloat(String key, float default);    // Gets the command line argument associated with this key.&lt;br /&gt;
public int getInt(String key, int default);          // Gets an int from the command line associated with this key.&lt;br /&gt;
public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key.&lt;br /&gt;
public String getString(String key, String default); // Gets a string corresponding to this key.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Header Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public void setN(int dim, int n);             // Used to set the number of elements in a dimension. For dimension 1, use an index value of 1.&lt;br /&gt;
public int getN(int dim);&lt;br /&gt;
public void setDelta(int dim, float delta);   // Used to set the delta for a dimension. For dimension 1, use an index value of 1, not 0.&lt;br /&gt;
public float getDelta(int dim);&lt;br /&gt;
public void setOrigin(int dim, float origin); // Used to set the origin for a dimension.  &lt;br /&gt;
public float getOrigin(int dim);&lt;br /&gt;
public void setLabel(int dim, String label);  // Sets the label for a dimension.&lt;br /&gt;
public String getLabel(int dim);&lt;br /&gt;
public void setUnit(int dim, String unit);    // Sets the unit for a dimension.&lt;br /&gt;
public String getUnit(int dim);&lt;br /&gt;
public void setFormat(String format);         // Sets the output format information, has no effect on how Java treats the data.&lt;br /&gt;
public String getFormat();&lt;br /&gt;
public void setPath(String path);             /* Sets the location of the binary file that corresponds to this header file. &lt;br /&gt;
                                                 Not used for writing information to an RSF file. */&lt;br /&gt;
public String getPath();&lt;br /&gt;
public void setName(String name);             /* Change the file name that this header corresponds to. When writing this info to an RSF file, &lt;br /&gt;
                                                 the API automatically will determine the binary file that goes along with this filename. */&lt;br /&gt;
public String getName();&lt;br /&gt;
public String toString();                     // Can be used to print out information about the header file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Writer Class==&lt;br /&gt;
&lt;br /&gt;
When writing out RSF files, the header file is output in the same directory as the java program was executed. The binary file is placed according to the DATAPATH environment variable. &amp;lt;tt&amp;gt;saveName&amp;lt;/tt&amp;gt; is the filename that you want to save your header to. Writing to standard out is not supported. All files must be saved via a name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[] data, String saveName);     // Writes a 1D array to an RSF Header and binary file&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][] data, String saveName);   // Writes a 2D array to an RSF header and binary file.&lt;br /&gt;
public static void writeRSF(RSFHeader header, float[][][] data, String saveName); // Writes a 3D array to an RSF header and binary file.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reader Class==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;java&amp;gt;&lt;br /&gt;
public static Header         readHeader(String headerFileName); // Used to parse the RSF Header file for information.&lt;br /&gt;
public static float[]        readBinary(RSFHeader header);      // Reads the RSF binary data file into a single array.&lt;br /&gt;
public static float[][]      readBinary2D(RSFHeader header);    // Reads the RSF binary data file into a 2D array.&lt;br /&gt;
public static float[][][]    readBinary3D(RSFHeader header);    // Reads the RSF binary data file into a 3D array.&lt;br /&gt;
&amp;lt;/java&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Python API=&lt;br /&gt;
&lt;br /&gt;
To use the python api, you need to import the rsf package via: &amp;lt;tt&amp;gt;import rsf.api&amp;lt;/tt&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: Madagascar now has automatic documentation, currently with Epydoc, and more to come. The information in the table below will be merged into it.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The rsf package has the following members:&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|+ Overview of the Python RSF API&lt;br /&gt;
! Class !! Use !! Constructor !! Example !! Available Methods&lt;br /&gt;
|-&lt;br /&gt;
|File&lt;br /&gt;
|-&lt;br /&gt;
|Filter&lt;br /&gt;
|-&lt;br /&gt;
|Movie&lt;br /&gt;
|-&lt;br /&gt;
|Input || Provides a basic way to read rsf files. || file = rsf.Input(name) || input = rsf.Input(&#039;&#039;name&#039;&#039;); n1 = input.int(&#039;n1&#039;) || read(data), data is a numpy array to be read into.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || close()&lt;br /&gt;
|-&lt;br /&gt;
| || || || || float(key, default=None), key is a string to be extracted, e.g. &#039;n1&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || int(key, default=None), key is a string to be extracted.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ints(key, num, default=None), key is a string, num is the number of ints.&lt;br /&gt;
|-&lt;br /&gt;
| || || || || put(key, val), key is a string to set the value for, val is a numerical value (int or float).&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ... and more, type help(rsf.Input) on a python interactive session for more information.&lt;br /&gt;
|-&lt;br /&gt;
|Output || Provides a way to output numpy arrays to rsf files.  || file = rsf.Output(name) || output=rsf.Output(name); output.write(data)&lt;br /&gt;
|-&lt;br /&gt;
|OverUnder&lt;br /&gt;
|-&lt;br /&gt;
|Overlay&lt;br /&gt;
|-&lt;br /&gt;
|Par || Provides a method for accessing rsf parameters passed from the command line. || par = rsf.Par() || par = rsf.Par(); velname = par.string(&#039;vel&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|SideBySide&lt;br /&gt;
|-&lt;br /&gt;
|Temp&lt;br /&gt;
|-&lt;br /&gt;
|Vplot || View vplot graphics files from within python. || plot = rsf.Vplot(name) || plot = rsf.Vplot(name); plot.show()&lt;br /&gt;
|-&lt;br /&gt;
|Vppen&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=SCons custom methods=&lt;br /&gt;
==Custom builders==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;File implemented in&#039;&#039;&#039; || &#039;&#039;&#039;Function&#039;&#039;&#039; || &#039;&#039;&#039;What it does&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Include&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Header || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Place&amp;lt;/tt&amp;gt; ||  RSFSRC/framework/bldutil.py || Place || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Pycompile&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py ||Pycompile || &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;RSF_Docmerge&amp;lt;/tt&amp;gt; || RSFSRC/framework/bldutil.py || Docmerge || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Other entities can be found in RSFSRC/framework/rsf/proj.py and tex.py&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1951</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1951"/>
		<updated>2011-07-24T15:57:47Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Fedora, CentOS, Scientific Linux, openSUSE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS, Scientific Linux, openSUSE==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
Names of packages that are runtime dependencies are &#039;&#039;&#039;highlighted&#039;&#039;&#039; in the tables below (task under construction).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1950</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1950"/>
		<updated>2011-07-24T15:50:05Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Fedora, CentOS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS, Scientific Linux, openSUSE==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, we should distinguish the subset of runtime dependencies (necessary to run already-compiled binaries installed through a package manager)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1949</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1949"/>
		<updated>2011-07-24T15:49:33Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* openSUSE 11.* */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, we should distinguish the subset of runtime dependencies (necessary to run already-compiled binaries installed through a package manager)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
	<entry>
		<id>https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1948</id>
		<title>Advanced Installation</title>
		<link rel="alternate" type="text/html" href="https://ahay.org/index.php?title=Advanced_Installation&amp;diff=1948"/>
		<updated>2011-07-24T15:48:24Z</updated>

		<summary type="html">&lt;p&gt;Nick: /* Fedora, CentOS, Scientific Linux, openSUSE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Fotolia_419157_XS.jpg|right|]]&lt;br /&gt;
Before reading this document, please familiarize yourself with the [[Installation|short Installation guide]].&lt;br /&gt;
=What the installation process does=&lt;br /&gt;
The term &amp;quot;installation&amp;quot; in the title is used for brevity, and it actually covers all three steps: configuration, build and install.&lt;br /&gt;
# Configure: determine what tools are available on the system and how they should be used to built the software. Creates a layer of abstraction so that the build is platform-independent. Should ideally either solve or flag all problems, so that the build either works, or does not proceed at all.&lt;br /&gt;
# Build: compiles the software and documentation using RSFSRC/build as a &amp;quot;workplace&amp;quot;&lt;br /&gt;
# Install: moves the compiled executables and the documentation to the final locations in $RSFROOT, sometimes changing filenames. Kept separate from build so that it can be done by root, and to avoid build failures leaving junk files all over the system.&lt;br /&gt;
A successful installation will have created in &amp;lt;tt&amp;gt;$RSFROOT&amp;lt;/tt&amp;gt; the following directories:&lt;br /&gt;
* &amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;: executable programs&lt;br /&gt;
* &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;: auto-generated HTML documentation&lt;br /&gt;
* &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt;: header files with info on library procedures; fonts&lt;br /&gt;
* &amp;lt;tt&amp;gt;lib/&amp;lt;/tt&amp;gt;: libraries and Python modules&lt;br /&gt;
&lt;br /&gt;
=Old (1.0 and 1.1) version installation=&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;tt&amp;gt;$RSFROOT/etc/madagascar/&amp;lt;/tt&amp;gt; as the location of &amp;lt;tt&amp;gt;env&amp;lt;/tt&amp;gt; scripts instead of &amp;lt;tt&amp;gt;$RSFROOT/share/madagascar/etc/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Old (0.9.9) version installation=&lt;br /&gt;
&lt;br /&gt;
====Environment variables====&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;bash&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=/usr/local/rsf # directory where Madagascar will be installed. &lt;br /&gt;
if [ -n &amp;quot;$PYTHONPATH&amp;quot; ]; then&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
export PYTHONPATH=$RSFROOT/lib&lt;br /&gt;
fi&lt;br /&gt;
export PATH=$RSFROOT/bin:$PATH&lt;br /&gt;
export DATAPATH=/var/tmp/&lt;br /&gt;
export MANPATH=$RSFROOT/share/man:$(manpath)&lt;br /&gt;
export LD_LIBRARY_PATH=$RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Notice the slash at the end of the &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; variable. &lt;br /&gt;
&lt;br /&gt;
Example configuration for &amp;lt;tt&amp;gt;csh&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tcsh&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setenv RSFROOT /usr/local/rsf&lt;br /&gt;
if ($?PYTHONPATH) then&lt;br /&gt;
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib&lt;br /&gt;
else&lt;br /&gt;
setenv PYTHONPATH $RSFROOT/lib&lt;br /&gt;
endif&lt;br /&gt;
set path = ($RSFROOT/bin $path)&lt;br /&gt;
setenv DATAPATH /var/tmp/&lt;br /&gt;
setenv MANPATH $RSFROOT/share/man:`manpath`&lt;br /&gt;
setenv LD_LIBRARY_PATH $RSFROOT/lib:$LD_LIBRARY_PATH&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notice the backticks surrounding the call to &amp;lt;tt&amp;gt;manpath&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Be aware that on some systems /var/tmp gets automatically cleaned at some intervals, so if you want to keep your data binaries for a long time, set &amp;lt;tt&amp;gt;DATAPATH&amp;lt;/tt&amp;gt; to another location where you have write access and that allows large files.&lt;br /&gt;
&lt;br /&gt;
====Software construction====&lt;br /&gt;
  &lt;br /&gt;
#Configuration. Change to the top source directory and run &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt; You can examine the &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file that this command generates.  Additional options are available. You can obtain a full list of customizable variables by running &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt;. For example, to install C++ and Fortran-90 API bindings in addition to the basic package, run &amp;lt;pre&amp;gt;./configure API=c++,fortran-90&amp;lt;/pre&amp;gt; &lt;br /&gt;
#Building and installing the package. Run &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; or the following two commands in succession:  &amp;lt;pre&amp;gt;make; make install&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons; scons install&amp;lt;/pre&amp;gt; If you need &amp;quot;root&amp;quot; privileges for installing under &amp;lt;tt&amp;gt;&amp;amp;#36;RSFROOT&amp;lt;/tt&amp;gt;, you may need to run &amp;lt;pre&amp;gt;su; scons install &amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;sudo scons install&amp;lt;/pre&amp;gt;&lt;br /&gt;
#Cleaning. To clean all intermediate files generated by SCons, run &amp;lt;pre&amp;gt;make clean&amp;lt;/pre&amp;gt; or &amp;lt;pre&amp;gt;scons -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Prerequisites=&lt;br /&gt;
Basic prerequisites are described in the [[Installation|short Installation guide]]. Here are some additional details. &lt;br /&gt;
==Python and SCons==&lt;br /&gt;
As described below under [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]], Madagascar supports the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons].  If your version of Python is older and you experience problems you should probably [http://www.python.org/ upgrade].&lt;br /&gt;
&lt;br /&gt;
Madagascar includes the latest stable version of SCons and the configure scripts will try to install it for you in RSFROOT if you don&#039;t have it already.  However, if you have an older version of SCons the configure scripts will not try to install the newer version. Your older version might work fine, but Madagascar attempts to support only the latest stable version of SCons, so if you have problems you should upgrade.&lt;br /&gt;
&lt;br /&gt;
To install the SCons bundled with Madagascar go to &amp;lt;tt&amp;gt;RSFSRC/scons&amp;lt;/tt&amp;gt;, unpack the tar file, and type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will install SCons in the standard location. You might need root privileges. If you don&#039;t have root privileges, or you don&#039;t want to interfere with the system SCons you can install it somewhere else with a --prefix option. A logical choice is to put it in RSFROOT like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
python setup.py install --prefix=$RSFROOT&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Location==&lt;br /&gt;
As long as you set the environment variables and directory permissions correctly, it does not matter in what part of your filesystem you place the install. If you have the luxury of installing anywhere, it is good practice to follow the [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and either:&lt;br /&gt;
# Install everything (including &amp;lt;tt&amp;gt;figs&amp;lt;/tt&amp;gt; if you do testing) under &amp;lt;tt&amp;gt;/usr/local/rsf&amp;lt;/tt&amp;gt;, with the source tree in &amp;lt;tt&amp;gt;/usr/local/rsf/src&amp;lt;/tt&amp;gt;, OR &lt;br /&gt;
# Put the source tree in &amp;lt;tt&amp;gt;/usr/local/src/rsf&amp;lt;/tt&amp;gt;, and specify &amp;lt;tt&amp;gt;RSFROOT=/usr/local&amp;lt;/tt&amp;gt;, so that header files and binaries go in &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;/usr/local/include&amp;lt;/tt&amp;gt;. To follow the standard, before installing set &amp;lt;tt&amp;gt;RSFDOC=/usr/local/share/rsf/doc&amp;lt;/tt&amp;gt; and create the appropriate directories. The auto-generated HTML documentation will get put there. Also, if installed, the figs directory for testing should be &amp;lt;tt&amp;gt;/usr/local/share/rsf/figs/&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Package Madagascar (i.e. build a RPM, etc) and install it in the default locations. For RPMs, those are as like the ones from the previous option, just directly in the &amp;lt;tt&amp;gt;/usr/&amp;lt;/tt&amp;gt; hierarchy, instead of in the &amp;lt;tt&amp;gt;/usr/local/&amp;lt;/tt&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
==Disk space==&lt;br /&gt;
At present (Feb 2007, r2530), the source directory containing the build tree from the development version was approx. 200Mb, the full installation (&amp;lt;tt&amp;gt;bin/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;doc/&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;include/&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;) is 31Mb, and &amp;lt;tt&amp;gt;figs/&amp;lt;/tt&amp;gt; (the optional directory if you want to do testing) is about 10 Gb. The stable version is significantly smaller.&lt;br /&gt;
&lt;br /&gt;
The only Madagascar-related directory where disk space can be an issue is &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. Real 3-D seismic datasets can be measured in Terabytes. Buggy programs/processing flows can fill up &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt;. A real problem are &amp;quot;disk memory leaks&amp;quot; -- removing header files with anything else than &amp;lt;tt&amp;gt;sfrm&amp;lt;/tt&amp;gt; will leave the binaries intact. Crashed jobs which start to write to binary but never get to write the header also produce &amp;quot;leaks&amp;quot;. Experience has shown that over time &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; inexorably fills up. You may need to &lt;br /&gt;
# keep irreplaceable data and expensive results in a separate place;&lt;br /&gt;
# remove the oldest files in &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; whenever the amount of free space declines under a preset threshold.&lt;br /&gt;
&lt;br /&gt;
==Dependencies==&lt;br /&gt;
Some platforms feature complete lists of dependencies. See [[Advanced Installation#Platform-specific installation advice | Platform-specific installation advice]] for details.&lt;br /&gt;
===C++ API===&lt;br /&gt;
A C++ compiler. SCons is smart and will try to find it for you. If it does not work specify the path to your compiler in the &amp;lt;tt&amp;gt;CXX&amp;lt;/tt&amp;gt; environment variable (can be passed as an option to the configuration script, like the &amp;lt;tt&amp;gt;API&amp;lt;/tt&amp;gt; one).&lt;br /&gt;
===F77 API===&lt;br /&gt;
A Fortran 77 compiler. If SCons does not find one, then you can either specify its path through the &amp;lt;tt&amp;gt;F77&amp;lt;/tt&amp;gt; variable, or if the executable is in your path, add its name to the list of F77 compilers in &amp;lt;tt&amp;gt;RSFSRC/configure.py&amp;lt;/tt&amp;gt; .&lt;br /&gt;
===F90 API===&lt;br /&gt;
Same as for Fortran 77 &amp;amp;ndash; just substitute &amp;lt;tt&amp;gt;F90&amp;lt;/tt&amp;gt;. If using the &amp;lt;tt&amp;gt;gfortran&amp;lt;/tt&amp;gt; compiler, make sure to get [http://gcc.gnu.org/wiki/GFortranBinaries the latest version]. If you have more than one compiler installed on your system, specify the desired one at configuration time:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
./configure API=f90 F90=/path/to/preferred/compiler&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Java API===&lt;br /&gt;
There are two styles of API, old (1.0 release and previous) and new. The two APIs are not compatible with each other.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;old&amp;quot; interface requires the Mines Java Toolkit for fast Java file IO. The Mines JTK, is an open-source Java package that can be downloaded from [http://inside.mines.edu/~dhale/jtk/ Mines JTK]. Currently, the &amp;quot;old&amp;quot; interface will also build alongside the new one if the MINESJTK environment variable exists, and can be used as was previously.&lt;br /&gt;
&lt;br /&gt;
To install the new API, you need the (Oracle) JDK. Set your JAVA_HOME environment variable to the location of the jdk (on Ubuntu 10.04 this is: /usr/lib/jvm/java-6-openjdk), then reconfigure (./configure API=java ...) and reinstall.  &lt;br /&gt;
&lt;br /&gt;
Ignore the SWIG warnings (there are lots). &lt;br /&gt;
&lt;br /&gt;
Make sure to set your LD_LIBRARY_PATH to $RSFROOT/lib .&lt;br /&gt;
&lt;br /&gt;
If you want to include additional Java packages, you can set them using your shell&#039;s CLASSPATH variable.  This environment variable is now automatically passed onto all Java classes in SCons.&lt;br /&gt;
&lt;br /&gt;
The installation can be tested using the example demonstrating the new API in api/java/test .&lt;br /&gt;
&lt;br /&gt;
===Matlab API===&lt;br /&gt;
Besides Matlab itself, you need Mex, which compiles C code into regular Matlab functions. Use the &amp;lt;tt&amp;gt;MATLAB&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;MEX&amp;lt;/tt&amp;gt; environment variables to specify their paths if they are installed, but not found.&lt;br /&gt;
===Octave API===&lt;br /&gt;
The Octave function compiler (&amp;lt;tt&amp;gt;mkoctfile&amp;lt;/tt&amp;gt;) is sometimes bundled in a separate package, so it may be missing from the Octave installation.&lt;br /&gt;
&lt;br /&gt;
===Python API===&lt;br /&gt;
This API requires [http://www.swig.org/ SWIG], [http://numpy.scipy.org/ numpy] and the Python development kit. Numpy requires Python 2.4 or newer (i.e. RHEL 5 or newer). However, these dependencies are unnecessary for the common case when Python is just used as [http://en.wikipedia.org/wiki/Glue_language glue] to create chains of programs, and it only needs to read the RSF header, and not the binary. To allow Python [http://en.wikipedia.org/wiki/Meta-programs metaprograms] in madagascar to function, and programming in this style to be done, a fallback development kit implementing only the header-related functionality will be installed in the lack of these dependencies.&lt;br /&gt;
&lt;br /&gt;
===Python modules in user space===&lt;br /&gt;
Python is an evolving language. Many large systems have old versions for stability reasons, and administrators of such large systems tend to not install all software users may wish, and to not allow access to rpm either. To install a module in your user space, download the tarball, unzip it, cd into the directory and run: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;python setup.py install --prefix=/path/to/your/place&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installer will create a subdirectory named &amp;lt;tt&amp;gt;lib&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt; under the directory above. These &amp;lt;tt&amp;gt;lib*&amp;lt;/tt&amp;gt; dirs will have a directory named &amp;lt;tt&amp;gt;python&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;python2.3&amp;lt;/tt&amp;gt; for example, and those will have a subdirectory named &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt;. Add all paths to these &amp;lt;tt&amp;gt;site-packages&amp;lt;/tt&amp;gt; subdirectories in your &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; environment variable. Some (&amp;lt;tt&amp;gt;numpy&amp;lt;/tt&amp;gt;) may create a &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory that needs to be added to &amp;lt;tt&amp;gt;PATH&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=Environment variables=&lt;br /&gt;
Besides the variables defined in env.sh or env.csh (see the [[Installation|short Installation guide]]), Madagascar programs may read the variables below. They usually have reasonable defaults and were introduced just to provide more power to the advanced user.&lt;br /&gt;
&lt;br /&gt;
For future documentation writers: the environment variables read by Madagascar that have not been documented below can be found by running the script &amp;lt;tt&amp;gt;$RSFSRC/admin/find_env_var.py&amp;lt;/tt&amp;gt;. If the script does not exist or does not work, a summary of all environment variable calls can be obtained by going to $RSFSRC, temporarily moving the directory &amp;lt;tt&amp;gt;build/&amp;lt;/tt&amp;gt; outside RSFSRC, and typing&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep environ.get *.py */*.py */*/*.py */*/*/*.py&lt;br /&gt;
grep getenv           */*.c  */*/*.c  */*/*/*.c&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar core==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar&#039;s non-graphic programs&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| RSF_DATASERVER || &amp;lt;nowiki&amp;gt;ftp://egl.beg.utexas.edu/&amp;lt;/nowiki&amp;gt; || Data server for benchmark datasets&lt;br /&gt;
|-&lt;br /&gt;
| RSFDOC || $RSFROOT/doc || Directory for the HTML self-doc&lt;br /&gt;
|-&lt;br /&gt;
| RSFFIGS || $RSFROOT/figs || Directory with figures for testing examples in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RSFALTFIGS || $RSFFIGS || Alternate directory with figures for testing examples not in $RSFSRC/book&lt;br /&gt;
|-&lt;br /&gt;
| RSFMEMSIZE || 100 || Maximum RAM (Mb) to be used by some programs  &lt;br /&gt;
|-&lt;br /&gt;
| RSFSRC || undefined || Root of the Madagascar source tree&lt;br /&gt;
|-&lt;br /&gt;
| TMPDATAPATH || $DATAPATH || Datapath for temporary files on local disk.&lt;br /&gt;
|-&lt;br /&gt;
| LATEX2HTML || undefined || LateX2HTML customization directory&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;|Variables introduced by Madagascar graphics programs &lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Default&#039;&#039;&#039; || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| DEFAULT_PAPER_SIZE || &amp;quot;letter&amp;quot; || For pspen. Other options: legal, a3, a4, a5.&lt;br /&gt;
|-&lt;br /&gt;
| FATMULT || ? || Fatness multiplication factor. &lt;br /&gt;
|-&lt;br /&gt;
| GIFBORDER || 0.25 || For vplot2gif (spacing)&lt;br /&gt;
|-&lt;br /&gt;
| GIFDELAY || 100 || For vplot2gif (for animations)&lt;br /&gt;
|-&lt;br /&gt;
| IMAGE_TYPE || &#039;png&#039; || Icon type for LateX2HTML &lt;br /&gt;
|-&lt;br /&gt;
| PATTERNMULT || None || Pattern multiplication factor  &lt;br /&gt;
|-&lt;br /&gt;
| PLOTSTYLE || None || Used in vplot&lt;br /&gt;
|-&lt;br /&gt;
| PPI || 75 || For vplot2gif (screen resolution)&lt;br /&gt;
|-&lt;br /&gt;
| PPMSCALE || 1 || For vplot2gif&lt;br /&gt;
|-&lt;br /&gt;
| PSBORDER || 0.05 || For vplot2eps (border around the plot)&lt;br /&gt;
|-&lt;br /&gt;
| PSPRINTER || postscript or colorps || For pspen&lt;br /&gt;
|-&lt;br /&gt;
| PSTEXPENOPTS || color=n fat=1 fatmult=1.5 invras=y || Other vplot2eps options &lt;br /&gt;
|-&lt;br /&gt;
| VPLOTFONTDIR || $RSFROOT/include || Dir with backup fonts in case the runtime-loaded vplot fonts are not found&lt;br /&gt;
|-&lt;br /&gt;
| VPLOTSPOOLDIR || /tmp || Where to put vplot tmp files&lt;br /&gt;
|-&lt;br /&gt;
| WSTYPE || &amp;quot;default&amp;quot; || Workstation type.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;background:#ffdead;&amp;quot;| Variables set by OS/other apps, read-only to Madagascar&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Name&#039;&#039;&#039; || &#039;&#039;&#039;Primarily used/set by&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| CWPROOT || Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
| DISPLAY || Operating System (OS)&lt;br /&gt;
|-&lt;br /&gt;
| HOME || OS&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || linker&lt;br /&gt;
|-&lt;br /&gt;
| MATLABPATH || Matlab&lt;br /&gt;
|-&lt;br /&gt;
| XAUTHORITY || X-Windows&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Used by the Madagascar build process==&lt;br /&gt;
Type &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; in RSFSRC to get a list of environment variables that affect the build process, with explanations, defaults and actual values. Below are more detailed explanations for some of them:&lt;br /&gt;
* &amp;lt;tt&amp;gt;RSF_CLUSTER&amp;lt;/tt&amp;gt;: used by &amp;lt;tt&amp;gt;pscons&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Used by the Matlab API==&lt;br /&gt;
To use the Matlab API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;MATLABPATH&amp;lt;/tt&amp;gt;&lt;br /&gt;
==Used by the Octave API==&lt;br /&gt;
To use the Octave API, you need to add &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to Octave&#039;s path. Determine Octave&#039;s version with&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
octave -v | head -1&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
If your version is lower than 2.9.6, type at a Unix command line:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;LOADPATH = &amp;quot;::$RSFROOT/lib/octave&amp;quot;&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
For later versions, use:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
echo &#039;addpath([getenv(&amp;quot;RSFROOT&amp;quot;) &amp;quot;/lib/octave&amp;quot;])&#039; &amp;gt;&amp;gt; ~/.octaverc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
==Used by the Java API==&lt;br /&gt;
New-style (post-1.0) API: Needs &amp;lt;tt&amp;gt;JAVA_HOME&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Old-style API (1.0 and before): The path to the downloaded Mines JTK must be specified in the MINESJTK environment variable in order to install the Java API. For example:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export MINESJTK=/home/user/edu_mines_jtk.jar&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==RSFROOT for NFS-shared user home directories==&lt;br /&gt;
Heterogeneous networks with user home directories shared through [http://en.wikipedia.org/wiki/Network_File_System_(protocol) NFS] are quite common in many institutions. In addition, even when the architecture is the same (i.e. 64-bit) and the operating system is the same (i.e. [http://en.wikipedia.org/wiki/RHEL RHEL]), the difference between operating system versions may be very significant because clusters may run legacy versions, while desktop workstations may run the latest-and-greatest (even beta), and entirely different Madagascar versions may be needed to support both. &lt;br /&gt;
&lt;br /&gt;
One possible solution of detecting the distribution version and architecture and setting RSFROOT appropriately is shown below. In the example network, all RHEL4 machines have the same architecture, but there are RHEL 3 machines with several architectures:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
REDHAT_RELEASE=`awk -F&#039;release&#039; &#039;{ print $2 }&#039; /etc/redhat-release | awk -F&#039; &#039; &#039;{ print $1 }&#039;`&lt;br /&gt;
&lt;br /&gt;
RSFROOT=/usr/local/rsf/rhel$REDHAT_RELEASE&lt;br /&gt;
&lt;br /&gt;
if [ $REDHAT_RELEASE == &#039;4&#039; ] ; then&lt;br /&gt;
    export RSFROOT&lt;br /&gt;
elif [ $REDHAT_RELEASE == &#039;3&#039; ] ; then&lt;br /&gt;
    export RSFROOT=$RSFROOT/$ARCH&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Of course, the Madagascar administrator will have to download appropriate versions of Madagascar to each $RSFROOT, and compile them on the appropriate system.&lt;br /&gt;
&lt;br /&gt;
If you have many kinds of systems to maintain, with multiple versions of Madagascar, and users have more than one shell, you may find it easy to outsource the complex logic to the easy-to-debug Python, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export RSFROOT=`$M8R_SETUP/get_rsfroot.py`&lt;br /&gt;
export PYTHONPATH=`$M8R_SETUP/edit_pythonpath.py`&lt;br /&gt;
export PATH=`$M8R_SETUP/edit_path.py`&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and similarly for (t)csh. The Python scripts determine the operating system and its version, determine the machine name, and simply print to stdout the desired string.&lt;br /&gt;
&lt;br /&gt;
==Eclipse + Pydev==&lt;br /&gt;
If you use [http://eclipse.org/ Eclipse] with [http://pydev.org/ Pydev], [http://pydev.org/manual_101_interpreter.html#id2 configure the interpreter] by adding &amp;lt;tt&amp;gt;$RSFROOT/lib&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;PYTHONPATH&amp;lt;/tt&amp;gt; for your chosen interpreter.&lt;br /&gt;
&lt;br /&gt;
=Platform-specific installation advice=&lt;br /&gt;
==Supported platforms==&lt;br /&gt;
Madagascar attempts to support any [http://en.wikipedia.org/wiki/POSIX POSIX-compliant] operating system demanded by users. For systems that bundle Python (i.e. Linux distributions, BSDs), backwards compatibility will attempt to cover those systems that were bundled with the oldest non-deprecated Python version currently supported by the latest stable version of [http://scons.org/ SCons]. For example, in early 2009 the stable SCons release (1.2) supported Python 2.2 or newer. [http://distrowatch.com/table.php?distribution=redhat Python 2.2 was bundled by RHEL3], so RHEL 3 and newer are supported. &lt;br /&gt;
&lt;br /&gt;
Attempts for backward compatibility with a given operating system are also stopped if the operating system itself becomes unsupported. For example, Python 2.2 was bundled by Fedora 1 and newer, but in January 2010 only Fedora 11 and 12 are actively maintained. Thus, in January 2010 Madagascar was not attempting to support Fedora 1, even though it included Python 2.2.&lt;br /&gt;
&lt;br /&gt;
Please keep in mind that the above statements constitute only general guidelines for what will be attempted, and do not constitute in any way a warranty of support. An application of the above guidelines to some Linux distributions follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Support info&#039;&#039;&#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Distribution&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Life Cycle&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Supported versions&lt;br /&gt;
|-&lt;br /&gt;
| RHEL/CentOS/Scientific Linux&lt;br /&gt;
| [https://www.redhat.com/security/updates/errata/ 7 years]&lt;br /&gt;
| &lt;br /&gt;
* 6 until 2017-11-30&lt;br /&gt;
* 5 until 2014-03-31&lt;br /&gt;
* 4 until 2012-02-29&lt;br /&gt;
|-&lt;br /&gt;
| Fedora&lt;br /&gt;
| [http://fedoraproject.org/wiki/Fedora_Release_Life_Cycle Release X maintained until one month after the release of X+2]&lt;br /&gt;
| &lt;br /&gt;
* 15 until 2012-06-24&lt;br /&gt;
* 14 until 2011-12-02&lt;br /&gt;
|-&lt;br /&gt;
| Ubuntu&lt;br /&gt;
| Releases every 6 mo, maintained for 1.5 yrs; LTS versions every 2 yrs, maintained for 5 yrs&lt;br /&gt;
| &lt;br /&gt;
* 11.10 until end of April 2013&lt;br /&gt;
* 11.04 until end of October 2012&lt;br /&gt;
* 10.10 until end of April 2012&lt;br /&gt;
* 10.04 until end of October 2011&lt;br /&gt;
* 8.04 LTS Server until end of April 2013&lt;br /&gt;
|-&lt;br /&gt;
| Debian&lt;br /&gt;
| [http://wiki.debian.org/DebianLenny Usually: stable releases every 1.5-3 yrs, release X maintained 1 yr after release X+1]&lt;br /&gt;
| &lt;br /&gt;
* 6 until its TBD end of life (approx. 2014)&lt;br /&gt;
* 5 until 2012-04&lt;br /&gt;
|- &lt;br /&gt;
| openSUSE&lt;br /&gt;
| [http://en.opensuse.org/Lifetime openSUSE releases Lifetime of 1.5-2.5 years]&lt;br /&gt;
| &lt;br /&gt;
* 11.4 until 2012-09-10&lt;br /&gt;
* 11.3 until 2012-01-15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Ubuntu==&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;Ubuntu 10.10 &#039;&#039;Maverick Meerkat&#039;&#039;&#039;&#039;&#039;, you can install all of Madagascar&#039;s dependencies by running &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libgd2-xpm-dev libglew1.5-dev libjpeg62-dev libx11-dev \&lt;br /&gt;
libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units libblas-dev \&lt;br /&gt;
libcairo2-dev libavcodec-dev libplplot-dev &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 9.04 version, the corresponding command is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install freeglut3-dev g++ gfortran libc6-dev libgd2-xpm-dev libglew1.5-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Earlier versions may work with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install mesa-libGL-devel g++ g77 libc6-dev libgd2-xpm-dev libglew-dev libjpeg62-dev \&lt;br /&gt;
libx11-dev libxaw7-dev libnetpbm10-dev swig python-dev python-scipy python-numpy libtiff4-dev scons units &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If working with the development version, you will also need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Fedora, CentOS==&lt;br /&gt;
&lt;br /&gt;
Dependency package names, sorted by Linux distribution and m8r feature they provide. Packages that are not included in the standard distro repositories are hyperlinked to their providers. The tables below cover build dependencies. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, we should distinguish the subset of runtime dependencies (necessary to run already-compiled binaries installed through a package manager)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: In the future, it should be possible for the configuration scripts to output the dependency tables below, so that they are guaranteed to be in synch with a given m8r version&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Minimal install (&amp;quot;Core&amp;quot;), publishing and development&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Core&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | LaTeX&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Development version&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | C++ API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | F77 API, F90 API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Python API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Java API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Octave API&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Matlab API&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig, python-devel&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons &lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab] with Mex&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| binutils, gcc, glibc-headers, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| numpy, swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?)&lt;br /&gt;
| octave, octave-devel&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| binutils, gcc, glibc-headers; python, scons (needs [http://dag.wieers.com/rpm/FAQ.php#B2 RPMforge&#039;s RHEL5 repository])&lt;br /&gt;
| ?&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-gfortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave, octave-devel]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| gcc, python, scons&lt;br /&gt;
| texlive-latex&lt;br /&gt;
| subversion&lt;br /&gt;
| gcc-c++&lt;br /&gt;
| gcc-fortran&lt;br /&gt;
| [http://numpy.scipy.org/ NumPy], swig&lt;br /&gt;
| Java (Sun&#039;s? IcedTea?), [http://inside.mines.edu/~dhale/jtk/ Mines JTK]&lt;br /&gt;
| [http://www.gnu.org/software/octave/ Octave]&lt;br /&gt;
| [http://www.mathworks.com/ Matlab]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Numerical and file manipulation utilities&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenMP&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | MPI&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | BLAS/ATLAS&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Interface to the Fast Discrete Curvelet Transform&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | sfunits&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| libgomp&lt;br /&gt;
| openmpi, openmpi-devel; openmpi-libs (?)&lt;br /&gt;
| blas, blas-devel, atlas, atlas-devel&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| units&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| [https://wave.eos.ubc.ca/Software/Licenced/ pyct]&lt;br /&gt;
| [http://www.gnu.org/software/units/units.html Gnu Units]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Graphics and visualization&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2gif&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | vplot2avi&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Some sort of movies?&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | TIFF output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | JPEG output&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | PLplot graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | OpenGL graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | X11 graphics&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | ppm (?)&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | unknown&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| gifsicle&lt;br /&gt;
| ffmpeg (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| ffmpeg-devel (needs the [http://rpmfusion.org/ RPM Fusion] repository enabled)&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| libXaw-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| libtiff-devel&lt;br /&gt;
| libjpeg-devel&lt;br /&gt;
| plplot-devel&lt;br /&gt;
| mesa-libGL-devel, freeglut, freeglut-devel&lt;br /&gt;
| xorg-x11-devel&lt;br /&gt;
| netpbm-devel&lt;br /&gt;
| cairo-devel, gd-devel, glew-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Other&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Inclusions from Seismic Unix&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 14, 15&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| [http://www.cwp.mines.edu/cwpcodes/ Seismic Unix]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command to install all dependencies present in the public repositories&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Usually package management software will not install again a package that is already installed, so it should be safe to copy and paste the command below to a command line:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 15&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python python-devel swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | Fedora 13&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils gcc glibc-headers scons texlive-latex subversion gcc-c++ gcc-gfortran numpy python swig octave octave-devel libgomp openmpi openmpi-devel blas blas-devel atlas atlas-devel units gifsicle ffmpeg ffmpeg-devel libtiff-devel libjpeg-devel plplot-devel mesa-libGL-devel freeglut freeglut-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | CentOS 5&lt;br /&gt;
| &#039;&#039;&#039;yum -y install&#039;&#039;&#039; binutils freeglut freeglut-devel gcc gcc-c++ gcc-gfortran glibc-headers libjpeg-devel libXaw-devel netpbm-devel&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background:#ffdead;&amp;quot; | openSUSE 11.0&lt;br /&gt;
| &#039;&#039;&#039;zypper install&#039;&#039;&#039; cairo-devel gcc gcc-c++ gcc-fortran gd-devel glew-devel libjpeg-devel libtiff-devel octave scons subversion texlive-latex xorg-x11-devel&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;List of runtime dependencies only&#039;&#039;&#039;&lt;br /&gt;
(needed by packagers of Madagascar in order to properly list dependencies):&lt;br /&gt;
UNDER CONSTRUCTION&lt;br /&gt;
&lt;br /&gt;
==Debian 5==&lt;br /&gt;
Specific dependencies:&lt;br /&gt;
* Debian 5.0 (&amp;quot;Lenny&amp;quot;): Please make sure you have the &amp;lt;tt&amp;gt;libc6-dev&amp;lt;/tt&amp;gt; package before trying to compile from source. The &amp;lt;tt&amp;gt;libXaw7-dev&amp;lt;/tt&amp;gt; package might be a dependency for &amp;lt;tt&amp;gt;xtpen&amp;lt;/tt&amp;gt; (was in Debian 4.0)&lt;br /&gt;
&lt;br /&gt;
==openSUSE 11.*==&lt;br /&gt;
The development version of m8r has dependencies beyond the packages installed by the default openSUSE 11.0 DVD install:&lt;br /&gt;
* To download the development version, you need &amp;lt;tt&amp;gt;subversion&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To compile the package, you need &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;gcc&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install the C++ API, you need &amp;lt;tt&amp;gt;gcc-c++&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install the F90 API, you need &amp;lt;tt&amp;gt;gcc-fortran&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install the Octave API, you need &amp;lt;tt&amp;gt;octave&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install &amp;lt;tt&amp;gt;sfbyte2jpg&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sfjpg2byte&amp;lt;/tt&amp;gt; you need &amp;lt;tt&amp;gt;libjpeg-devel&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install the vplot graphics, you need &amp;lt;tt&amp;gt;xorg-x11-devel&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install LaTeX for building papers and books, you need &amp;lt;tt&amp;gt;texlive-latex&amp;lt;/tt&amp;gt;&lt;br /&gt;
* To install some graphics programs, you need &amp;lt;tt&amp;gt;cairo-devel&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gd-devel&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;glew-devel&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;libtiff-devel&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Packages can be installed by running as root &amp;lt;tt&amp;gt;zypper install &amp;lt;package name&amp;gt;&amp;lt;/tt&amp;gt;. The graphical front-end to Zypper integrated with YaST2 can of course be used as well (Geeko button... Applications... System... Configuration... Install Software)&lt;br /&gt;
&lt;br /&gt;
==Yellow Dog Linux 6.1 on Sony PlayStation 3==&lt;br /&gt;
See [http://www.reproducibility.org/rsflog/uploads/Friday_Seminar_Madagascar_on_PS3.ppt W. Burnett&#039;s guide (PowerPoint)]&lt;br /&gt;
&lt;br /&gt;
==Mac OS X==&lt;br /&gt;
First of all, a [https://sourceforge.net/project/showfiles.php?group_id=162909 Mac OS X precompiled binary package] of the latest Madagascar stable release is available for download from SourceForge.  &lt;br /&gt;
&lt;br /&gt;
If you want to install a development version of Madagascar, the following might help. &lt;br /&gt;
# &amp;lt;b&amp;gt;C compiler&amp;lt;/b&amp;gt; for Mac OS X. You can download the precompiled binary package of &amp;lt;b&amp;gt;Xcode&amp;lt;/b&amp;gt; tools, including the &amp;lt;b&amp;gt;gcc&amp;lt;/b&amp;gt; compiler, from [http://developer.apple.com/tools/xcode/ Apple]. Other sources are:&lt;br /&gt;
#* [http://www.macports.org/ MacPorts], an easy-to-use system for compiling, installing, and upgrading open-source software on Mac OS X.&lt;br /&gt;
#* [http://www.finkproject.org/ Fink], a tool that brings the full world of Unix Open Source software to Mac OS X. &lt;br /&gt;
# [http://subversion.tigris.org/ Subversion] client for Mac OS X. There are two methods to install Subversion in Mac OS X: you can use &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; to update &amp;lt;b&amp;gt;Subversion client&amp;lt;/b&amp;gt; package or the precompiled binary. Some useful information can be found on the [http://www.wikihow.com/Install-Subversion-on-Mac-OS-X Wikihow website] and [http://downloads.open.collab.net/binaries.html Collab]. You can use &amp;lt;b&amp;gt;Subversion&amp;lt;/b&amp;gt; to [[Download#Current_development_version|download the development version]] of the &amp;lt;tt&amp;gt;Madagascar&amp;lt;/tt&amp;gt; source code. Next, follow [[Installation|Installation instructions]] to install. &lt;br /&gt;
# [[SEGTeX]], a &amp;lt;b&amp;gt;LaTeX&amp;lt;/b&amp;gt; package for geophysical publications. To use &amp;lt;b&amp;gt;SEGTeX&amp;lt;/b&amp;gt;, you may need [http://www.tug.org/texlive/ TeX Live]. &amp;lt;b&amp;gt;MacPorts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;Fink&amp;lt;/b&amp;gt; provide an easy way to install it with commands &amp;lt;tt&amp;gt;sudo port install texlive&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;sudo fink install texlive&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==MS Windows==&lt;br /&gt;
Due to its size, this topic has been assigned [[Windows | its own Wiki page]].&lt;br /&gt;
&lt;br /&gt;
==How to adapt Madagascar to a new platform==&lt;br /&gt;
The most laborious part of adapting madagascar to a new platform is finding the proper dependency names. This usually proceeds as follows: dependency X fails with a &amp;quot;missing file&amp;quot; error either as a header file in &amp;lt;tt&amp;gt;config.log&amp;lt;/tt&amp;gt;, or a missing library during the build step. Possible package names are found through an internet search for the missing file name and the distribution name or by using specific [http://rpm.pbone.net/ rpm search tools]. Packages are installed and the configure (and, if necessary) build processes are repeated until the error goes away.&lt;br /&gt;
&lt;br /&gt;
=Multi-user installs=&lt;br /&gt;
Some organizations may find it desirable to deny write access of some users to all RSFSRC/RSFROOT except their own user directory. Fortunately, this can be easily done by placing the restricted user dirs outside RSFSRC/RSFROOT, i.e. in their home dirs, say /home/joe/rsfsrc. In order to move a user&#039;s directory out of RSFSRC, you must:&lt;br /&gt;
* &amp;quot;tell&amp;quot; the SConstruct in the user&#039;s dir where to find RSFSRC so that when the user builds in his directory, it can import &amp;lt;tt&amp;gt;configure.py&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; You do that by setting the environment variable RSFSRC to the absolute path of the Madagascar source root, and by making sure that lines 2 and 3 in the users&#039; SConstruct files are&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
srcroot = os.environ.get(&#039;RSFSRC&#039;, &#039;../..&#039;)&lt;br /&gt;
sys.path.append(srcroot)&lt;br /&gt;
&amp;lt;/python&amp;gt; &lt;br /&gt;
and then replace &amp;lt;tt&amp;gt;../..&amp;lt;/tt&amp;gt; throughout the SConstruct using &amp;lt;tt&amp;gt;os.path.join&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;srcroot&amp;lt;/tt&amp;gt; variable.&lt;br /&gt;
* &amp;quot;tell&amp;quot; the build scripts about the user&#039;s dir, so that it is included in the builds launched from RSFSRC. You do that with a symbolic link:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s /home/joe/rsfsrc $RSFSRC/user/joe&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&#039;&#039;When the link exists&#039;&#039;, those of Joe&#039;s programs that are mentioned in the &amp;quot;prog&amp;quot; string in SConstruct get included in the distribution, complete with self-doc. If Joe is just learning how to code and his stuff breaks the build, just remove the symbolic link. Even if build+installs are done after the link is removed, his stable programs and self-doc will continue to remain installed system-wide as long as the admin does not type &amp;lt;tt&amp;gt;scons -c install&amp;lt;/tt&amp;gt; (not likely).&lt;br /&gt;
* point the user&#039;s RSFDOC environment variable to a location where the user has write access&lt;br /&gt;
* edit the users&#039; SConstruct so that it uses the RSF library and headers already installed in $RSFROOT/lib and $RSFROOT/include , instead of building again the whole &amp;lt;tt&amp;gt;librsf&amp;lt;/tt&amp;gt; with user-specific flags in &amp;lt;tt&amp;gt;RSFSRC/filt/lib/&amp;lt;/tt&amp;gt;. To do that, replace in the user&#039;s SConstruct the env.Prepend statement with&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
rsfroot = os.environ.get(&#039;RSFROOT&#039;,&#039;/usr/local/rsf&#039;)&lt;br /&gt;
&lt;br /&gt;
env.Prepend(CPPPATH=[os.path.join(rsfroot,&#039;include&#039;)],&lt;br /&gt;
            LIBPATH=[os.path.join(rsfroot,&#039;lib&#039;)],&lt;br /&gt;
            LIBS=[&#039;rsf&#039;])&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
* If the link from RSFSRC to Joe&#039;s directory was not made, add Joe&#039;s directory to his own path so that he can execute his own binaries.&lt;br /&gt;
&lt;br /&gt;
To understand how $DATAPATH disk space issues may become an issue in a multi-user environment, refer to the [[Advanced_Installation#Disk_space|Disk Space subsection]] at the beginning of this document.&lt;br /&gt;
&lt;br /&gt;
=Keeping your stuff separate=&lt;br /&gt;
A user may add his own programs and recipes to the Madagascar system. He may also create his own computational examples, data, and locked figures for testing. All of these components can be placed in their default locations, but it is not necessary to make them public. To keep these items private simply do not add them to the repository.&lt;br /&gt;
&lt;br /&gt;
However, it might be desirable to keep these components in separate places. For example, if you keep your private programs in RSFSRC/user you will have to remember to make a copy somewhere else if you ever want to delete the Madagascar installation to perform a fresh install. Yup, I deleted all my programs that way once. Good thing I had a back up! Fortunately, it is easy to keep each of these components in a separate place if desired.&lt;br /&gt;
&lt;br /&gt;
==Keeping programs separate==&lt;br /&gt;
User programs are ordinarily kept in a subdirectory of RSFSRC/user.  However, if you want to keep your programs separate all you have to do is put your subdirectory somewhere else and make a link to it in RSFSRC/user:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
ln -s path_to_my_programs $RSFSRC/user/my_programs&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The additional instructions above for &amp;quot;multi-user installs&amp;quot; are for the case where the other users do not have write access to RSFSRC.  However, if you have full write access and only want to keep the programs in a separate place the link is the only thing you need.&lt;br /&gt;
&lt;br /&gt;
==Keeping recipes separate==&lt;br /&gt;
Computational recipes written in Python and imported by the SConstruct file of a workflow are normally stored in RSFSRC/book/Recipes.  The install process copies these recipes to a directory like $RSFROOT/lib/python2.5/site-packages/rsf/recipes and adds this directory to your PYTHONPATH so that Python can find them.&lt;br /&gt;
&lt;br /&gt;
However, you can put you own recipes anywhere you want.  You only have to add that place to your PYTHONPATH like this (bash):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
export PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
Or like this (csh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
setenv PYTHONPATH=${PYTHONPATH}:path_to_my_recipes&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping examples separate==&lt;br /&gt;
Madagascar&#039;s public collection of example workflows are stored in RSFSRC/book, but you can put your private workflows anywhere you want.  No special instructions are required.&lt;br /&gt;
&lt;br /&gt;
However, Madagascar assumes that the workflows are organized into a three-level book/chapter/section directory hierarchy when it creates a directory tree for the data and locked figures associated with your workflow. It is not required, but it might be easier to find the data and locked figures if you put your workflows in a three-level directory tree something like this: path_to_my_book/chapter/section/SConstruct.&lt;br /&gt;
&lt;br /&gt;
==Keeping data separate==&lt;br /&gt;
The location of the data portion of your *.rsf files is controlled by your DATAPATH environment variable.  However, you may want to keep the data for your private workflows in a different place, or several different places, than the data created by the public examples in RSFSRC/book.  The way to do that is to temporarily change the DATAPATH variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;DATAPATH&#039;] = &#039;path_to_my_private_data&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Keeping locked figures separate==&lt;br /&gt;
The command &amp;quot;scons lock&amp;quot; in the directory of a workflow will store a &amp;quot;locked&amp;quot; copy of your figures for regression testing.  Normally these figures are stored in the location pointed to by your RSFFIGS variable, and that is where the figures from the figures repository should be stored for testing in RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
However, you may want to keep your private figures in a different place.  The way to do that is to temporarily change the RSFFIGS variable in the SConstruct &#039;&#039;before&#039;&#039; importing rsf.proj like this:&lt;br /&gt;
&amp;lt;python&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.environ[&#039;RSFFIGS&#039;] = &#039;path_to_my_private_figures&#039;&lt;br /&gt;
&lt;br /&gt;
from rsf.proj import *&lt;br /&gt;
&amp;lt;/python&amp;gt;&lt;br /&gt;
If you also create a RSFALTFIGS environment variable pointing to path_to_my_private_figures, then the testing script sffiglist will automatically test your figures against those in RSFALTFIGS when the sffiglist command is executed from a location outside of RSFSRC/book.&lt;br /&gt;
&lt;br /&gt;
=Capturing error and warning messages=&lt;br /&gt;
The messages during configuration are few and their importance quite high, so they should be watched &amp;quot;in person&amp;quot;. A complete log of the configuration process is recorded in RSFSRC/configure.log&lt;br /&gt;
&lt;br /&gt;
Console messages generated during the build step can be captured to a log file and observed at the same time with a command like this (tcsh):&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
nice +10 nohup /usr/bin/time -p scons -k |&amp;amp; tee log_build.asc&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
The log file can be of course named otherwise than &amp;lt;tt&amp;gt;log_build.asc&amp;lt;/tt&amp;gt;. The file can be later grepped for error and warnings with commands such as:&lt;br /&gt;
&amp;lt;bash&amp;gt;&lt;br /&gt;
grep -c error log_build.asc&lt;br /&gt;
grep error log_build.asc | awk &#039;/error.c/ {next}; /error.h/ {next}; /error.o/ {next}; {print}&#039;&lt;br /&gt;
grep -c warning log_build.asc&lt;br /&gt;
grep warning log_build.asc | awk &#039;/imaginary constants are a GCC extension/ {next}; {print}&#039;&lt;br /&gt;
&amp;lt;/bash&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Advanced troubleshooting=&lt;br /&gt;
* If you removed one of your programs or changed its name, and &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fails with &amp;quot;Source &amp;lt;tt&amp;gt;oldprogname&amp;lt;/tt&amp;gt; not found, needed by target install&amp;quot;, and you cleaned everything there was to clean but still get this message, remove &amp;lt;tt&amp;gt;RSFSRC/.sconsign*&amp;lt;/tt&amp;gt;&lt;br /&gt;
* If during &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; you get a &amp;lt;tt&amp;gt;DBAccessError : (13, &#039;Permission denied&#039;)&amp;lt;/tt&amp;gt; in some reproducible papers, check permissions in your &amp;lt;tt&amp;gt;$DATAPATH&amp;lt;/tt&amp;gt; directory. This is where SCons places database &amp;quot;.sconsign&amp;quot; files for its dependencies (according to the rules in &amp;lt;tt&amp;gt;rsf.proj&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;rsf.tex&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* If &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt; fail due to an a bug introduced in a tool you are certain you will not use, a quick workaround for the problem is already built into scons: the &amp;lt;tt&amp;gt;-k&amp;lt;/tt&amp;gt; option, which means &amp;quot;keep going&amp;quot;. Thus, if you use &amp;lt;tt&amp;gt;scons -k&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;scons -k install&amp;lt;/tt&amp;gt;, SCons will not be able to build the failed component, or anything that depends on it, but it will keep going and make everything else that it can.&lt;br /&gt;
&lt;br /&gt;
=Further support=&lt;br /&gt;
Subscribe to the [https://lists.sourceforge.net/lists/listinfo/rsf-user rsf-user mailing list].&lt;/div&gt;</summary>
		<author><name>Nick</name></author>
	</entry>
</feed>