ULTRA DOCUMENT

Stewart A. Brown


Disclaimer

Introduction

An ULTRA II Tutorial

Basics of Data Files and Accessing Them

ULTRA II Input Data Files
ASCII ULTRA File Format
Binary ULTRA File Format
Getting Input Data into ULTRA II

ULTRA Curves

ULTRA II Notes

Ultra Commands

I/O Commands
Math Operations Which Do Not Generate a New Curve
Math Operations Which Do Generate a New Curve
Environmental Inquiry Commands
Curve Inquiry Commands
Environmental Control Commands
Plot Control Commands
Curve Control Commands
Commands Useful for Writing Extensions

ULTRA Variables

The Default ULTRA II Environment

Constants and Values
Functions
Synonyms
Display and I/O Environment

Graphical Output in ULTRA II

PostScript
CGM

Extending ULTRA II

Cookbook Examples
Gaussian Curve Generator
First Order Differential Equation Solver

Installation/Availability

UNIX
DOS
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk
MAC
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk

Internal Documentation

Related Documents

Disclaimer

This document was prepared as an account of work sponsored by an agency of the United States Government. Nneither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, including the warranties of merchantability and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Part of this work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

Introduction

ULTRA II is a program for the presentation, manipulation, and analysis of 1D data sets (i.e., x, y pairs). Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets. An example of this is the Fast Fourier Transform (FFT) capability in ULTRA II.

The principal object with which ULTRA II works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. ULTRA II operates on curves.

ULTRA II is a portable tool. It runs on machines from supercomputers to PCs. It runs under UNIX, DOS, and MAC OS. Its portability derives from the PACT libraries which provide the portable graphics and the SCHEME interpreter engine which are the main foundation of ULTRA II.

ULTRA II can read and write ASCII data files or PDB files with ULTRA curves in them. PDBLib is another PACT tool which provides portable, self-describing, binary data files. PDBLib has specific functionality to write ULTRA curves. This provides an easy and convenient way for applications to produce ULTRA files. The advantage of PDB files over ASCII files is that PDB files are about 1/3 the size of a corresponding ASCII file and can be written or read about 10 times faster. Interested readers will find references to PACT documentation later in this manual.

Before plunging into descriptions of the commands and variables for ULTRA II, a brief tutorial is given.

An ULTRA II Tutorial

This section gives a tutorial introduction to ULTRA II. A sample session is run which highlights the basic ULTRA commands.

NOTE: In ULTRA commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example,

a:f
or

5:9
This notation is shorthand for the thru procedure.

To start up ULTRA II essarilyray *arr; {object *op; op = SS_mk_object(arr, G_NUM_ARRAY, SELF_EV, arr->type); op->print = _wr_gnum_array; op->release = _rl_gnum_array;; return(op); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* ARRAYP - function version of ARRAYP macro * - this is the function mentioned in step #5 */ object *arrayp(obj) object *obj; {return(ARRAYP(obj) ? SS_t : SS_f); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* MK_ARRAY - allocate and return a array * - form: (make-array ) * - this is a step #6 function */ static object *mk_array(argl) object *argl; {array *arr; long size, bpi; char *type, ltype[MAXLINE]; type = NULL; size = 0L; SS_args(argl, SC_STRING_I, &type, SC_LONG_I, &size, SC_LONG_I, &bpi, 0); arr = MAKE(array); sprintf(ltype, "%s *", type); arr->type = SC_strsave(ltype); arr->length = size; arr->data = (byte *) MAKE_N(char, size*bpi); return(_mk_array(arr)); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* INSTALL_ARRAY_FUNCS - install some array extensions to SX * - this is step #7 */ void install_array_funcs() { /* install the fundamental array operations */ SS_install("array?", "Return #t if the object is a numeric array, and #f otherwise", SS_sargs, arrayp, SS_PR_PROC); SS_install("make-array", "Allocate and return an array of the specified type and size", SS_nargs, mk_array, SS_PR_PROC); /* suggestions for other SCHEME level operations with arrays */ #if 0 SS_install("list->array", "Return a numeric array built from a list of numbers", SS_nargs, list_array, SS_PR_PROC); SS_install("array->list", "Return a list of numbers built from a numeric array", SS_sargs, array_list, SS_PR_PROC); SS_install("resize-array", "Reallocate the given array to the specified size", SS_nargs, resz_array, SS_PR_PROC); SS_install("array-ref", "Reference the nth element of an array", SS_nargs, array_ref, SS_PR_PROC); SS_install("array-set!", "Set the nth element of an array", SS_nargs, array_set, SS_PR_PROC); SS_install("array-length", "Return the length of the given numeric array", SS_sargs, num_arr_len, SS_PR_PROC); #endif return; /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/


Compiling and Loading

To compile your C programs you must use one or the other (not both) of the following

#include <scheme.h>

#include <sx.h>

in the source files which deal with the interpreter.

To link your application you must use the following libraries in the order specified. For SCHEME only programs use:

-lscheme -lppc -lpdb -lpml -lscore [-lm ...]
For SX programs use:

-lsx -lscheme -lpanacea -lpgs [-lX11] -lppc -lpdb -lpml -lscore [-lm ...]

Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.

Each system has different naming conventions for its libraries and the reader is assumed to understand the appropriate naming conventions as well as knowing how to tell the linker to find the installed PACT libraries on each system that they use.

Calling Interpreted Routines from Compiled Routines

The only real trick to having a compiled routine call an interpreted one is to map the compiled parameters or arguments into a representation which the evaluator is able to use. Naturally, that means making a list of SCHEME objects out of the arguments and applying the interpreted function to them. The interpreted function can be specified by name so that part it easy. To make the correct SCHEME objects (referred to simply as objects from now on - sorry but the LISP folks co-opted that term long before the OOP folks) from the compiled variables, you need only give the integer object type designation (see the previous section) and a pointer to the variable for each argument. The function SS_call_scheme does the rest. Specifically, it builds a list of objects from the supplied information, looks up the named procedure, applies it to the list of arguments, and returns the value which the interpreted routine returns. The important part to note here is that SS_call_scheme returns a SCHEME object! Note also the similarity between SS_call_scheme and SS_args. These two functions are complementary and realize the majority of the run time interface between interpreted and compiled functions.

Here is an example continuing the array example of the last section:


    object *rv;
    char *type;
    int n, bpi;

/* invoke the SCHEME level function create-array
 * this is the same as (create-array "float" 10 4)
 */
    type = "float";
    n    = 10;
    bpi  = sizeof(float);
    rv = SS_call_scheme("create-array",
                        SC_STRING_I, type,
                        SC_INTEGER_I, &n,
                        SC_INTEGER_I, &bpi,
                        0);
                        .
                        .
                        .
    long length;
    char *ntype;
    double *data;

    length = ARRAY_LENGTH(rv);
    ntype  = ARRAY_TYPE(rv);
    data   = ARRAY_DATA(rv);


The SCHEME level use of this example is limited only by the number of functions defined so far to manipulate such objects. Here is a fragment of SCHEME code showing their use:


 (let* ((x (make-array "double" 10 8)))

     (if (array? x)

          (printf nil "We have an array: %s\n" x)))

       
If we assume the existence of the functions alluded to in install_array_funcs we can show a more useful example:



(let* ((x (make-array "double" 10 8)))

    (array-set! x 5 15.34)

    (examine x 5)

       

(define (examine x n)

   (cond ((and (pair? x) (< n (length x)))

          (printf nil "List element %d = %s\n" n (list-ref x n)))

         ((and (array? x) (< n (array-length x)))

          (printf nil "Array element %d = %s\n" n (array-ref x n)))))




Related Documents

SX is one part of PACT, a set of tools for portable code development and visualization. Users of SX may be interested in the other parts of PACT especially since the various aspects of SX are derived from PACT. That is the graphics is handled by PGS; and the binary file handling is done by PDBLib.

The list of PACT Documents is:

PACT User’s GuideUCRL-MA-112087
SCORE User’s ManualUCRL-MA-108976 Rev.1
PPC User’s ManualUCRL-MA-108964 Rev.1
PML User’s ManualUCRL-MA-108965 Rev.1
PDBLib User’s ManualM-270 Rev.2
PGS User’s ManualUCRL-MA-108966 Rev.1
PANACEA User’s ManualM-276 Rev.2
ULTRA II User’s ManualUCRL-MA-108967 Rev.1
PDBDiff User’s ManualUCRL-MA-108975 Rev.1
PDBView User’s ManualUCRL-MA-108968 Rev.1
SX User’s ManualUCRL-MA-112315Current Document

Last modified: Fri Jul 30 09:25:58 PDT 1999

Modified by: rodrigues2@llnl.gov

./usr/share/doc/pact/html/ultra.html0100644000000000000000000042714306755524243016331 0ustar rootroot ULTRA Document

ULTRA DOCUMENT

Stewart A. Brown


Disclaimer

Introduction

An ULTRA II Tutorial

Basics of Data Files and Accessing Them

ULTRA II Input Data Files
ASCII ULTRA File Format
Binary ULTRA File Format
Getting Input Data into ULTRA II

ULTRA Curves

ULTRA II Notes

Ultra Commands

I/O Commands
Math Operations Which Do Not Generate a New Curve
Math Operations Which Do Generate a New Curve
Environmental Inquiry Commands
Curve Inquiry Commands
Environmental Control Commands
Plot Control Commands
Curve Control Commands
Commands Useful for Writing Extensions

ULTRA Variables

The Default ULTRA II Environment

Constants and Values
Functions
Synonyms
Display and I/O Environment

Graphical Output in ULTRA II

PostScript
CGM

Extending ULTRA II

Cookbook Examples
Gaussian Curve Generator
First Order Differential Equation Solver

Installation/Availability

UNIX
DOS
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk
MAC
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk

Internal Documentation

Related Documents

Disclaimer

This document was prepared as an account of work sponsored by an agency of the United States Government. Nneither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, including the warranties of merchantability and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Part of this work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

Introduction

ULTRA II is a program for the presentation, manipulation, and analysis of 1D data sets (i.e., x, y pairs). Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets. An example of this is the Fast Fourier Transform (FFT) capability in ULTRA II.

The principal object with which ULTRA II works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. ULTRA II operates on curves.

ULTRA II is a portable tool. It runs on machines from supercomputers to PCs. It runs under UNIX, DOS, and MAC OS. Its portability derives from the PACT libraries which provide the portable graphics and the SCHEME interpreter engine which are the main foundation of ULTRA II.

ULTRA II can read and write ASCII data files or PDB files with ULTRA curves in them. PDBLib is another PACT tool which provides portable, self-describing, binary data files. PDBLib has specific functionality to write ULTRA curves. This provides an easy and convenient way for applications to produce ULTRA files. The advantage of PDB files over ASCII files is that PDB files are about 1/3 the size of a corresponding ASCII file and can be written or read about 10 times faster. Interested readers will find references to PACT documentation later in this manual.

Before plunging into descriptions of the commands and variables for ULTRA II, a brief tutorial is given.

An ULTRA II Tutorial

This section gives a tutorial introduction to ULTRA II. A sample session is run which highlights the basic ULTRA commands.

NOTE: In ULTRA commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example,

a:f
or

5:9
This notation is shorthand for the thru procedure.

To start up ULTRA II essarilyray *arr; {object *op; op = SS_mk_object(arr, G_NUM_ARRAY, SELF_EV, arr->type); op->print = _wr_gnum_array; op->release = _rl_gnum_array;; return(op); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* ARRAYP - function version of ARRAYP macro * - this is the function mentioned in step #5 */ object *arrayp(obj) object *obj; {return(ARRAYP(obj) ? SS_t : SS_f); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* MK_ARRAY - allocate and return a array * - form: (make-array ) * - this is a step #6 function */ static object *mk_array(argl) object *argl; {array *arr; long size, bpi; char *type, ltype[MAXLINE]; type = NULL; size = 0L; SS_args(argl, SC_STRING_I, &type, SC_LONG_I, &size, SC_LONG_I, &bpi, 0); arr = MAKE(array); sprintf(ltype, "%s *", type); arr->type = SC_strsave(ltype); arr->length = size; arr->data = (byte *) MAKE_N(char, size*bpi); return(_mk_array(arr)); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* INSTALL_ARRAY_FUNCS - install some array extensions to SX * - this is step #7 */ void install_array_funcs() { /* install the fundamental array operations */ SS_install("array?", "Return #t if the object is a numeric array, and #f otherwise", SS_sargs, arrayp, SS_PR_PROC); SS_install("make-array", "Allocate and return an array of the specified type and size", SS_nargs, mk_array, SS_PR_PROC); /* suggestions for other SCHEME level operations with arrays */ #if 0 SS_install("list->array", "Return a numeric array built from a list of numbers", SS_nargs, list_array, SS_PR_PROC); SS_install("array->list", "Return a list of numbers built from a numeric array", SS_sargs, array_list, SS_PR_PROC); SS_install("resize-array", "Reallocate the given array to the specified size", SS_nargs, resz_array, SS_PR_PROC); SS_install("array-ref", "Reference the nth element of an array", SS_nargs, array_ref, SS_PR_PROC); SS_install("array-set!", "Set the nth element of an array", SS_nargs, array_set, SS_PR_PROC); SS_install("array-length", "Return the length of the given numeric array", SS_sargs, num_arr_len, SS_PR_PROC); #endif return; /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/


Compiling and Loading

To compile your C programs you must use one or the other (not both) of the following

#include <scheme.h>

#include <sx.h>

in the source files which deal with the interpreter.

To link your application you must use the following libraries in the order specified. For SCHEME only programs use:

-lscheme -lppc -lpdb -lpml -lscore [-lm ...]
For SX programs use:

-lsx -lscheme -lpanacea -lpgs [-lX11] -lppc -lpdb -lpml -lscore [-lm ...]

Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.

Each system has different naming conventions for its libraries and the reader is assumed to understand the appropriate naming conventions as well as knowing how to tell the linker to find the installed PACT libraries on each system that they use.

Calling Interpreted Routines from Compiled Routines

The only real trick to having a compiled routine call an interpreted one is to map the compiled parameters or arguments into a representation which the evaluator is able to use. Naturally, that means making a list of SCHEME objects out of the arguments and applying the interpreted function to them. The interpreted function can be specified by name so that part it easy. To make the correct SCHEME objects (referred to simply as objects from now on - sorry but the LISP folks co-opted that term long before the OOP folks) from the compiled variables, you need only give the integer object type designation (see the previous section) and a pointer to the variable for each argument. The function SS_call_scheme does the rest. Specifically, it builds a list of objects from the supplied information, looks up the named procedure, applies it to the list of arguments, and returns the value which the interpreted routine returns. The important part to note here is that SS_call_scheme returns a SCHEME object! Note also the similarity between SS_call_scheme and SS_args. These two functions are complementary and realize the majority of the run time interface between interpreted and compiled functions.

Here is an example continuing the array example of the last section:


    object *rv;
    char *type;
    int n, bpi;

/* invoke the SCHEME level function create-array
 * this is the same as (create-array "float" 10 4)
 */
    type = "float";
    n    = 10;
    bpi  = sizeof(float);
    rv = SS_call_scheme("create-array",
                        SC_STRING_I, type,
                        SC_INTEGER_I, &n,
                        SC_INTEGER_I, &bpi,
                        0);
                        .
                        .
                        .
    long length;
    char *ntype;
    double *data;

    length = ARRAY_LENGTH(rv);
    ntype  = ARRAY_TYPE(rv);
    data   = ARRAY_DATA(rv);


The SCHEME level use of this example is limited only by the number of functions defined so far to manipulate such objects. Here is a fragment of SCHEME code showing their use:


 (let* ((x (make-array "double" 10 8)))

     (if (array? x)

          (printf nil "We have an array: %s\n" x)))

       
If we assume the existence of the functions alluded to in install_array_funcs we can show a more useful example:



(let* ((x (make-array "double" 10 8)))

    (array-set! x 5 15.34)

    (examine x 5)

       

(define (examine x n)

   (cond ((and (pair? x) (< n (length x)))

          (printf nil "List element %d = %s\n" n (list-ref x n)))

         ((and (array? x) (< n (array-length x)))

          (printf nil "Array element %d = %s\n" n (array-ref x n)))))




Related Documents

SX is one part of PACT, a set of tools for portable code development and visualization. Users of SX may be interested in the other parts of PACT especially since the various aspects of SX are derived from PACT. That is the graphics is handled by PGS; and the binary file handling is done by PDBLib.

The list of PACT Documents is:

PACT User’s GuideUCRL-MA-112087
SCORE User’s ManualUCRL-MA-108976 Rev.1
PPC User’s ManualUCRL-MA-108964 Rev.1
PML User’s ManualUCRL-MA-108965 Rev.1
PDBLib User’s ManualM-270 Rev.2
PGS User’s ManualUCRL-MA-108966 Rev.1
PANACEA User’s ManualM-276 Rev.2
ULTRA II User’s ManualUCRL-MA-108967 Rev.1
PDBDiff User’s ManualUCRL-MA-108975 Rev.1
PDBView User’s ManualUCRL-MA-108968 Rev.1
SX User’s ManualUCRL-MA-112315Current Document

Last modified: Fri Jul 30 09:25:58 PDT 1999

Modified by: rodrigues2@llnl.gov

./usr/share/doc/pact/html/ultra.html0100644000000000000000000042714306755524243016331 0ustar rootroot ULTRA Document

ULTRA DOCUMENT

Stewart A. Brown


Disclaimer

Introduction

An ULTRA II Tutorial

Basics of Data Files and Accessing Them

ULTRA II Input Data Files
ASCII ULTRA File Format
Binary ULTRA File Format
Getting Input Data into ULTRA II

ULTRA Curves

ULTRA II Notes

Ultra Commands

I/O Commands
Math Operations Which Do Not Generate a New Curve
Math Operations Which Do Generate a New Curve
Environmental Inquiry Commands
Curve Inquiry Commands
Environmental Control Commands
Plot Control Commands
Curve Control Commands
Commands Useful for Writing Extensions

ULTRA Variables

The Default ULTRA II Environment

Constants and Values
Functions
Synonyms
Display and I/O Environment

Graphical Output in ULTRA II

PostScript
CGM

Extending ULTRA II

Cookbook Examples
Gaussian Curve Generator
First Order Differential Equation Solver

Installation/Availability

UNIX
DOS
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk
MAC
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk

Internal Documentation

Related Documents

Disclaimer

This document was prepared as an account of work sponsored by an agency of the United States Government. Nneither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, including the warranties of merchantability and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Part of this work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

Introduction

ULTRA II is a program for the presentation, manipulation, and analysis of 1D data sets (i.e., x, y pairs). Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets. An example of this is the Fast Fourier Transform (FFT) capability in ULTRA II.

The principal object with which ULTRA II works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. ULTRA II operates on curves.

ULTRA II is a portable tool. It runs on machines from supercomputers to PCs. It runs under UNIX, DOS, and MAC OS. Its portability derives from the PACT libraries which provide the portable graphics and the SCHEME interpreter engine which are the main foundation of ULTRA II.

ULTRA II can read and write ASCII data files or PDB files with ULTRA curves in them. PDBLib is another PACT tool which provides portable, self-describing, binary data files. PDBLib has specific functionality to write ULTRA curves. This provides an easy and convenient way for applications to produce ULTRA files. The advantage of PDB files over ASCII files is that PDB files are about 1/3 the size of a corresponding ASCII file and can be written or read about 10 times faster. Interested readers will find references to PACT documentation later in this manual.

Before plunging into descriptions of the commands and variables for ULTRA II, a brief tutorial is given.

An ULTRA II Tutorial

This section gives a tutorial introduction to ULTRA II. A sample session is run which highlights the basic ULTRA commands.

NOTE: In ULTRA commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example,

a:f
or

5:9
This notation is shorthand for the thru procedure.

To start up ULTRA II essarilyray *arr; {object *op; op = SS_mk_object(arr, G_NUM_ARRAY, SELF_EV, arr->type); op->print = _wr_gnum_array; op->release = _rl_gnum_array;; return(op); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* ARRAYP - function version of ARRAYP macro * - this is the function mentioned in step #5 */ object *arrayp(obj) object *obj; {return(ARRAYP(obj) ? SS_t : SS_f); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* MK_ARRAY - allocate and return a array * - form: (make-array ) * - this is a step #6 function */ static object *mk_array(argl) object *argl; {array *arr; long size, bpi; char *type, ltype[MAXLINE]; type = NULL; size = 0L; SS_args(argl, SC_STRING_I, &type, SC_LONG_I, &size, SC_LONG_I, &bpi, 0); arr = MAKE(array); sprintf(ltype, "%s *", type); arr->type = SC_strsave(ltype); arr->length = size; arr->data = (byte *) MAKE_N(char, size*bpi); return(_mk_array(arr)); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* INSTALL_ARRAY_FUNCS - install some array extensions to SX * - this is step #7 */ void install_array_funcs() { /* install the fundamental array operations */ SS_install("array?", "Return #t if the object is a numeric array, and #f otherwise", SS_sargs, arrayp, SS_PR_PROC); SS_install("make-array", "Allocate and return an array of the specified type and size", SS_nargs, mk_array, SS_PR_PROC); /* suggestions for other SCHEME level operations with arrays */ #if 0 SS_install("list->array", "Return a numeric array built from a list of numbers", SS_nargs, list_array, SS_PR_PROC); SS_install("array->list", "Return a list of numbers built from a numeric array", SS_sargs, array_list, SS_PR_PROC); SS_install("resize-array", "Reallocate the given array to the specified size", SS_nargs, resz_array, SS_PR_PROC); SS_install("array-ref", "Reference the nth element of an array", SS_nargs, array_ref, SS_PR_PROC); SS_install("array-set!", "Set the nth element of an array", SS_nargs, array_set, SS_PR_PROC); SS_install("array-length", "Return the length of the given numeric array", SS_sargs, num_arr_len, SS_PR_PROC); #endif return; /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/


Compiling and Loading

To compile your C programs you must use one or the other (not both) of the following

#include <scheme.h>

#include <sx.h>

in the source files which deal with the interpreter.

To link your application you must use the following libraries in the order specified. For SCHEME only programs use:

-lscheme -lppc -lpdb -lpml -lscore [-lm ...]
For SX programs use:

-lsx -lscheme -lpanacea -lpgs [-lX11] -lppc -lpdb -lpml -lscore [-lm ...]

Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.

Each system has different naming conventions for its libraries and the reader is assumed to understand the appropriate naming conventions as well as knowing how to tell the linker to find the installed PACT libraries on each system that they use.

Calling Interpreted Routines from Compiled Routines

The only real trick to having a compiled routine call an interpreted one is to map the compiled parameters or arguments into a representation which the evaluator is able to use. Naturally, that means making a list of SCHEME objects out of the arguments and applying the interpreted function to them. The interpreted function can be specified by name so that part it easy. To make the correct SCHEME objects (referred to simply as objects from now on - sorry but the LISP folks co-opted that term long before the OOP folks) from the compiled variables, you need only give the integer object type designation (see the previous section) and a pointer to the variable for each argument. The function SS_call_scheme does the rest. Specifically, it builds a list of objects from the supplied information, looks up the named procedure, applies it to the list of arguments, and returns the value which the interpreted routine returns. The important part to note here is that SS_call_scheme returns a SCHEME object! Note also the similarity between SS_call_scheme and SS_args. These two functions are complementary and realize the majority of the run time interface between interpreted and compiled functions.

Here is an example continuing the array example of the last section:


    object *rv;
    char *type;
    int n, bpi;

/* invoke the SCHEME level function create-array
 * this is the same as (create-array "float" 10 4)
 */
    type = "float";
    n    = 10;
    bpi  = sizeof(float);
    rv = SS_call_scheme("create-array",
                        SC_STRING_I, type,
                        SC_INTEGER_I, &n,
                        SC_INTEGER_I, &bpi,
                        0);
                        .
                        .
                        .
    long length;
    char *ntype;
    double *data;

    length = ARRAY_LENGTH(rv);
    ntype  = ARRAY_TYPE(rv);
    data   = ARRAY_DATA(rv);


The SCHEME level use of this example is limited only by the number of functions defined so far to manipulate such objects. Here is a fragment of SCHEME code showing their use:


 (let* ((x (make-array "double" 10 8)))

     (if (array? x)

          (printf nil "We have an array: %s\n" x)))

       
If we assume the existence of the functions alluded to in install_array_funcs we can show a more useful example:



(let* ((x (make-array "double" 10 8)))

    (array-set! x 5 15.34)

    (examine x 5)

       

(define (examine x n)

   (cond ((and (pair? x) (< n (length x)))

          (printf nil "List element %d = %s\n" n (list-ref x n)))

         ((and (array? x) (< n (array-length x)))

          (printf nil "Array element %d = %s\n" n (array-ref x n)))))




Related Documents

SX is one part of PACT, a set of tools for portable code development and visualization. Users of SX may be interested in the other parts of PACT especially since the various aspects of SX are derived from PACT. That is the graphics is handled by PGS; and the binary file handling is done by PDBLib.

The list of PACT Documents is:

PACT User’s GuideUCRL-MA-112087
SCORE User’s ManualUCRL-MA-108976 Rev.1
PPC User’s ManualUCRL-MA-108964 Rev.1
PML User’s ManualUCRL-MA-108965 Rev.1
PDBLib User’s ManualM-270 Rev.2
PGS User’s ManualUCRL-MA-108966 Rev.1
PANACEA User’s ManualM-276 Rev.2
ULTRA II User’s ManualUCRL-MA-108967 Rev.1
PDBDiff User’s ManualUCRL-MA-108975 Rev.1
PDBView User’s ManualUCRL-MA-108968 Rev.1
SX User’s ManualUCRL-MA-112315Current Document

Last modified: Fri Jul 30 09:25:58 PDT 1999

Modified by: rodrigues2@llnl.gov

./usr/share/doc/pact/html/ultra.html0100644000000000000000000042714306755524243016331 0ustar rootroot ULTRA Document

ULTRA DOCUMENT

Stewart A. Brown


Disclaimer

Introduction

An ULTRA II Tutorial

Basics of Data Files and Accessing Them

ULTRA II Input Data Files
ASCII ULTRA File Format
Binary ULTRA File Format
Getting Input Data into ULTRA II

ULTRA Curves

ULTRA II Notes

Ultra Commands

I/O Commands
Math Operations Which Do Not Generate a New Curve
Math Operations Which Do Generate a New Curve
Environmental Inquiry Commands
Curve Inquiry Commands
Environmental Control Commands
Plot Control Commands
Curve Control Commands
Commands Useful for Writing Extensions

ULTRA Variables

The Default ULTRA II Environment

Constants and Values
Functions
Synonyms
Display and I/O Environment

Graphical Output in ULTRA II

PostScript
CGM

Extending ULTRA II

Cookbook Examples
Gaussian Curve Generator
First Order Differential Equation Solver

Installation/Availability

UNIX
DOS
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk
MAC
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk

Internal Documentation

Related Documents

Disclaimer

This document was prepared as an account of work sponsored by an agency of the United States Government. Nneither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, including the warranties of merchantability and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Part of this work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

Introduction

ULTRA II is a program for the presentation, manipulation, and analysis of 1D data sets (i.e., x, y pairs). Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets. An example of this is the Fast Fourier Transform (FFT) capability in ULTRA II.

The principal object with which ULTRA II works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. ULTRA II operates on curves.

ULTRA II is a portable tool. It runs on machines from supercomputers to PCs. It runs under UNIX, DOS, and MAC OS. Its portability derives from the PACT libraries which provide the portable graphics and the SCHEME interpreter engine which are the main foundation of ULTRA II.

ULTRA II can read and write ASCII data files or PDB files with ULTRA curves in them. PDBLib is another PACT tool which provides portable, self-describing, binary data files. PDBLib has specific functionality to write ULTRA curves. This provides an easy and convenient way for applications to produce ULTRA files. The advantage of PDB files over ASCII files is that PDB files are about 1/3 the size of a corresponding ASCII file and can be written or read about 10 times faster. Interested readers will find references to PACT documentation later in this manual.

Before plunging into descriptions of the commands and variables for ULTRA II, a brief tutorial is given.

An ULTRA II Tutorial

This section gives a tutorial introduction to ULTRA II. A sample session is run which highlights the basic ULTRA commands.

NOTE: In ULTRA commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example,

a:f
or

5:9
This notation is shorthand for the thru procedure.

To start up ULTRA II essarilyray *arr; {object *op; op = SS_mk_object(arr, G_NUM_ARRAY, SELF_EV, arr->type); op->print = _wr_gnum_array; op->release = _rl_gnum_array;; return(op); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* ARRAYP - function version of ARRAYP macro * - this is the function mentioned in step #5 */ object *arrayp(obj) object *obj; {return(ARRAYP(obj) ? SS_t : SS_f); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* MK_ARRAY - allocate and return a array * - form: (make-array ) * - this is a step #6 function */ static object *mk_array(argl) object *argl; {array *arr; long size, bpi; char *type, ltype[MAXLINE]; type = NULL; size = 0L; SS_args(argl, SC_STRING_I, &type, SC_LONG_I, &size, SC_LONG_I, &bpi, 0); arr = MAKE(array); sprintf(ltype, "%s *", type); arr->type = SC_strsave(ltype); arr->length = size; arr->data = (byte *) MAKE_N(char, size*bpi); return(_mk_array(arr)); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* INSTALL_ARRAY_FUNCS - install some array extensions to SX * - this is step #7 */ void install_array_funcs() { /* install the fundamental array operations */ SS_install("array?", "Return #t if the object is a numeric array, and #f otherwise", SS_sargs, arrayp, SS_PR_PROC); SS_install("make-array", "Allocate and return an array of the specified type and size", SS_nargs, mk_array, SS_PR_PROC); /* suggestions for other SCHEME level operations with arrays */ #if 0 SS_install("list->array", "Return a numeric array built from a list of numbers", SS_nargs, list_array, SS_PR_PROC); SS_install("array->list", "Return a list of numbers built from a numeric array", SS_sargs, array_list, SS_PR_PROC); SS_install("resize-array", "Reallocate the given array to the specified size", SS_nargs, resz_array, SS_PR_PROC); SS_install("array-ref", "Reference the nth element of an array", SS_nargs, array_ref, SS_PR_PROC); SS_install("array-set!", "Set the nth element of an array", SS_nargs, array_set, SS_PR_PROC); SS_install("array-length", "Return the length of the given numeric array", SS_sargs, num_arr_len, SS_PR_PROC); #endif return; /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/


Compiling and Loading

To compile your C programs you must use one or the other (not both) of the following

#include <scheme.h>

#include <sx.h>

in the source files which deal with the interpreter.

To link your application you must use the following libraries in the order specified. For SCHEME only programs use:

-lscheme -lppc -lpdb -lpml -lscore [-lm ...]
For SX programs use:

-lsx -lscheme -lpanacea -lpgs [-lX11] -lppc -lpdb -lpml -lscore [-lm ...]

Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.

Each system has different naming conventions for its libraries and the reader is assumed to understand the appropriate naming conventions as well as knowing how to tell the linker to find the installed PACT libraries on each system that they use.

Calling Interpreted Routines from Compiled Routines

The only real trick to having a compiled routine call an interpreted one is to map the compiled parameters or arguments into a representation which the evaluator is able to use. Naturally, that means making a list of SCHEME objects out of the arguments and applying the interpreted function to them. The interpreted function can be specified by name so that part it easy. To make the correct SCHEME objects (referred to simply as objects from now on - sorry but the LISP folks co-opted that term long before the OOP folks) from the compiled variables, you need only give the integer object type designation (see the previous section) and a pointer to the variable for each argument. The function SS_call_scheme does the rest. Specifically, it builds a list of objects from the supplied information, looks up the named procedure, applies it to the list of arguments, and returns the value which the interpreted routine returns. The important part to note here is that SS_call_scheme returns a SCHEME object! Note also the similarity between SS_call_scheme and SS_args. These two functions are complementary and realize the majority of the run time interface between interpreted and compiled functions.

Here is an example continuing the array example of the last section:


    object *rv;
    char *type;
    int n, bpi;

/* invoke the SCHEME level function create-array
 * this is the same as (create-array "float" 10 4)
 */
    type = "float";
    n    = 10;
    bpi  = sizeof(float);
    rv = SS_call_scheme("create-array",
                        SC_STRING_I, type,
                        SC_INTEGER_I, &n,
                        SC_INTEGER_I, &bpi,
                        0);
                        .
                        .
                        .
    long length;
    char *ntype;
    double *data;

    length = ARRAY_LENGTH(rv);
    ntype  = ARRAY_TYPE(rv);
    data   = ARRAY_DATA(rv);


The SCHEME level use of this example is limited only by the number of functions defined so far to manipulate such objects. Here is a fragment of SCHEME code showing their use:


 (let* ((x (make-array "double" 10 8)))

     (if (array? x)

          (printf nil "We have an array: %s\n" x)))

       
If we assume the existence of the functions alluded to in install_array_funcs we can show a more useful example:



(let* ((x (make-array "double" 10 8)))

    (array-set! x 5 15.34)

    (examine x 5)

       

(define (examine x n)

   (cond ((and (pair? x) (< n (length x)))

          (printf nil "List element %d = %s\n" n (list-ref x n)))

         ((and (array? x) (< n (array-length x)))

          (printf nil "Array element %d = %s\n" n (array-ref x n)))))




Related Documents

SX is one part of PACT, a set of tools for portable code development and visualization. Users of SX may be interested in the other parts of PACT especially since the various aspects of SX are derived from PACT. That is the graphics is handled by PGS; and the binary file handling is done by PDBLib.

The list of PACT Documents is:

PACT User’s GuideUCRL-MA-112087
SCORE User’s ManualUCRL-MA-108976 Rev.1
PPC User’s ManualUCRL-MA-108964 Rev.1
PML User’s ManualUCRL-MA-108965 Rev.1
PDBLib User’s ManualM-270 Rev.2
PGS User’s ManualUCRL-MA-108966 Rev.1
PANACEA User’s ManualM-276 Rev.2
ULTRA II User’s ManualUCRL-MA-108967 Rev.1
PDBDiff User’s ManualUCRL-MA-108975 Rev.1
PDBView User’s ManualUCRL-MA-108968 Rev.1
SX User’s ManualUCRL-MA-112315Current Document

Last modified: Fri Jul 30 09:25:58 PDT 1999

Modified by: rodrigues2@llnl.gov

./usr/share/doc/pact/html/ultra.html0100644000000000000000000042714306755524243016331 0ustar rootroot ULTRA Document

ULTRA DOCUMENT

Stewart A. Brown


Disclaimer

Introduction

An ULTRA II Tutorial

Basics of Data Files and Accessing Them

ULTRA II Input Data Files
ASCII ULTRA File Format
Binary ULTRA File Format
Getting Input Data into ULTRA II

ULTRA Curves

ULTRA II Notes

Ultra Commands

I/O Commands
Math Operations Which Do Not Generate a New Curve
Math Operations Which Do Generate a New Curve
Environmental Inquiry Commands
Curve Inquiry Commands
Environmental Control Commands
Plot Control Commands
Curve Control Commands
Commands Useful for Writing Extensions

ULTRA Variables

The Default ULTRA II Environment

Constants and Values
Functions
Synonyms
Display and I/O Environment

Graphical Output in ULTRA II

PostScript
CGM

Extending ULTRA II

Cookbook Examples
Gaussian Curve Generator
First Order Differential Equation Solver

Installation/Availability

UNIX
DOS
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk
MAC
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk

Internal Documentation

Related Documents

Disclaimer

This document was prepared as an account of work sponsored by an agency of the United States Government. Nneither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, including the warranties of merchantability and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Part of this work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

Introduction

ULTRA II is a program for the presentation, manipulation, and analysis of 1D data sets (i.e., x, y pairs). Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets. An example of this is the Fast Fourier Transform (FFT) capability in ULTRA II.

The principal object with which ULTRA II works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. ULTRA II operates on curves.

ULTRA II is a portable tool. It runs on machines from supercomputers to PCs. It runs under UNIX, DOS, and MAC OS. Its portability derives from the PACT libraries which provide the portable graphics and the SCHEME interpreter engine which are the main foundation of ULTRA II.

ULTRA II can read and write ASCII data files or PDB files with ULTRA curves in them. PDBLib is another PACT tool which provides portable, self-describing, binary data files. PDBLib has specific functionality to write ULTRA curves. This provides an easy and convenient way for applications to produce ULTRA files. The advantage of PDB files over ASCII files is that PDB files are about 1/3 the size of a corresponding ASCII file and can be written or read about 10 times faster. Interested readers will find references to PACT documentation later in this manual.

Before plunging into descriptions of the commands and variables for ULTRA II, a brief tutorial is given.

An ULTRA II Tutorial

This section gives a tutorial introduction to ULTRA II. A sample session is run which highlights the basic ULTRA commands.

NOTE: In ULTRA commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example,

a:f
or

5:9
This notation is shorthand for the thru procedure.

To start up ULTRA II essarilyray *arr; {object *op; op = SS_mk_object(arr, G_NUM_ARRAY, SELF_EV, arr->type); op->print = _wr_gnum_array; op->release = _rl_gnum_array;; return(op); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* ARRAYP - function version of ARRAYP macro * - this is the function mentioned in step #5 */ object *arrayp(obj) object *obj; {return(ARRAYP(obj) ? SS_t : SS_f); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* MK_ARRAY - allocate and return a array * - form: (make-array ) * - this is a step #6 function */ static object *mk_array(argl) object *argl; {array *arr; long size, bpi; char *type, ltype[MAXLINE]; type = NULL; size = 0L; SS_args(argl, SC_STRING_I, &type, SC_LONG_I, &size, SC_LONG_I, &bpi, 0); arr = MAKE(array); sprintf(ltype, "%s *", type); arr->type = SC_strsave(ltype); arr->length = size; arr->data = (byte *) MAKE_N(char, size*bpi); return(_mk_array(arr)); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* INSTALL_ARRAY_FUNCS - install some array extensions to SX * - this is step #7 */ void install_array_funcs() { /* install the fundamental array operations */ SS_install("array?", "Return #t if the object is a numeric array, and #f otherwise", SS_sargs, arrayp, SS_PR_PROC); SS_install("make-array", "Allocate and return an array of the specified type and size", SS_nargs, mk_array, SS_PR_PROC); /* suggestions for other SCHEME level operations with arrays */ #if 0 SS_install("list->array", "Return a numeric array built from a list of numbers", SS_nargs, list_array, SS_PR_PROC); SS_install("array->list", "Return a list of numbers built from a numeric array", SS_sargs, array_list, SS_PR_PROC); SS_install("resize-array", "Reallocate the given array to the specified size", SS_nargs, resz_array, SS_PR_PROC); SS_install("array-ref", "Reference the nth element of an array", SS_nargs, array_ref, SS_PR_PROC); SS_install("array-set!", "Set the nth element of an array", SS_nargs, array_set, SS_PR_PROC); SS_install("array-length", "Return the length of the given numeric array", SS_sargs, num_arr_len, SS_PR_PROC); #endif return; /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/


Compiling and Loading

To compile your C programs you must use one or the other (not both) of the following

#include <scheme.h>

#include <sx.h>

in the source files which deal with the interpreter.

To link your application you must use the following libraries in the order specified. For SCHEME only programs use:

-lscheme -lppc -lpdb -lpml -lscore [-lm ...]
For SX programs use:

-lsx -lscheme -lpanacea -lpgs [-lX11] -lppc -lpdb -lpml -lscore [-lm ...]

Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.

Each system has different naming conventions for its libraries and the reader is assumed to understand the appropriate naming conventions as well as knowing how to tell the linker to find the installed PACT libraries on each system that they use.

Calling Interpreted Routines from Compiled Routines

The only real trick to having a compiled routine call an interpreted one is to map the compiled parameters or arguments into a representation which the evaluator is able to use. Naturally, that means making a list of SCHEME objects out of the arguments and applying the interpreted function to them. The interpreted function can be specified by name so that part it easy. To make the correct SCHEME objects (referred to simply as objects from now on - sorry but the LISP folks co-opted that term long before the OOP folks) from the compiled variables, you need only give the integer object type designation (see the previous section) and a pointer to the variable for each argument. The function SS_call_scheme does the rest. Specifically, it builds a list of objects from the supplied information, looks up the named procedure, applies it to the list of arguments, and returns the value which the interpreted routine returns. The important part to note here is that SS_call_scheme returns a SCHEME object! Note also the similarity between SS_call_scheme and SS_args. These two functions are complementary and realize the majority of the run time interface between interpreted and compiled functions.

Here is an example continuing the array example of the last section:


    object *rv;
    char *type;
    int n, bpi;

/* invoke the SCHEME level function create-array
 * this is the same as (create-array "float" 10 4)
 */
    type = "float";
    n    = 10;
    bpi  = sizeof(float);
    rv = SS_call_scheme("create-array",
                        SC_STRING_I, type,
                        SC_INTEGER_I, &n,
                        SC_INTEGER_I, &bpi,
                        0);
                        .
                        .
                        .
    long length;
    char *ntype;
    double *data;

    length = ARRAY_LENGTH(rv);
    ntype  = ARRAY_TYPE(rv);
    data   = ARRAY_DATA(rv);


The SCHEME level use of this example is limited only by the number of functions defined so far to manipulate such objects. Here is a fragment of SCHEME code showing their use:


 (let* ((x (make-array "double" 10 8)))

     (if (array? x)

          (printf nil "We have an array: %s\n" x)))

       
If we assume the existence of the functions alluded to in install_array_funcs we can show a more useful example:



(let* ((x (make-array "double" 10 8)))

    (array-set! x 5 15.34)

    (examine x 5)

       

(define (examine x n)

   (cond ((and (pair? x) (< n (length x)))

          (printf nil "List element %d = %s\n" n (list-ref x n)))

         ((and (array? x) (< n (array-length x)))

          (printf nil "Array element %d = %s\n" n (array-ref x n)))))




Related Documents

SX is one part of PACT, a set of tools for portable code development and visualization. Users of SX may be interested in the other parts of PACT especially since the various aspects of SX are derived from PACT. That is the graphics is handled by PGS; and the binary file handling is done by PDBLib.

The list of PACT Documents is:

PACT User’s GuideUCRL-MA-112087
SCORE User’s ManualUCRL-MA-108976 Rev.1
PPC User’s ManualUCRL-MA-108964 Rev.1
PML User’s ManualUCRL-MA-108965 Rev.1
PDBLib User’s ManualM-270 Rev.2
PGS User’s ManualUCRL-MA-108966 Rev.1
PANACEA User’s ManualM-276 Rev.2
ULTRA II User’s ManualUCRL-MA-108967 Rev.1
PDBDiff User’s ManualUCRL-MA-108975 Rev.1
PDBView User’s ManualUCRL-MA-108968 Rev.1
SX User’s ManualUCRL-MA-112315Current Document

Last modified: Fri Jul 30 09:25:58 PDT 1999

Modified by: rodrigues2@llnl.gov

./usr/share/doc/pact/html/ultra.html0100644000000000000000000042714306755524243016331 0ustar rootroot ULTRA Document

ULTRA DOCUMENT

Stewart A. Brown


Disclaimer

Introduction

An ULTRA II Tutorial

Basics of Data Files and Accessing Them

ULTRA II Input Data Files
ASCII ULTRA File Format
Binary ULTRA File Format
Getting Input Data into ULTRA II

ULTRA Curves

ULTRA II Notes

Ultra Commands

I/O Commands
Math Operations Which Do Not Generate a New Curve
Math Operations Which Do Generate a New Curve
Environmental Inquiry Commands
Curve Inquiry Commands
Environmental Control Commands
Plot Control Commands
Curve Control Commands
Commands Useful for Writing Extensions

ULTRA Variables

The Default ULTRA II Environment

Constants and Values
Functions
Synonyms
Display and I/O Environment

Graphical Output in ULTRA II

PostScript
CGM

Extending ULTRA II

Cookbook Examples
Gaussian Curve Generator
First Order Differential Equation Solver

Installation/Availability

UNIX
DOS
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk
MAC
Using ULTRA II from a floppy disk
Using ULTRA II from a hard disk

Internal Documentation

Related Documents

Disclaimer

This document was prepared as an account of work sponsored by an agency of the United States Government. Nneither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, including the warranties of merchantability and fitness for a particular purpose, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Part of this work performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

Introduction

ULTRA II is a program for the presentation, manipulation, and analysis of 1D data sets (i.e., x, y pairs). Presentation refers to the capability to display, and make hard copies of data plots. Manipulation refers to the capability to excerpt, shift, and scale data sets. Analysis refers to the capability to combine data sets in various ways to create new data sets. An example of this is the Fast Fourier Transform (FFT) capability in ULTRA II.

The principal object with which ULTRA II works is the curve. A curve is an object which consists of an array of x values, an array of y values, a number of points (the length of the x and y arrays), and an ASCII label. ULTRA II operates on curves.

ULTRA II is a portable tool. It runs on machines from supercomputers to PCs. It runs under UNIX, DOS, and MAC OS. Its portability derives from the PACT libraries which provide the portable graphics and the SCHEME interpreter engine which are the main foundation of ULTRA II.

ULTRA II can read and write ASCII data files or PDB files with ULTRA curves in them. PDBLib is another PACT tool which provides portable, self-describing, binary data files. PDBLib has specific functionality to write ULTRA curves. This provides an easy and convenient way for applications to produce ULTRA files. The advantage of PDB files over ASCII files is that PDB files are about 1/3 the size of a corresponding ASCII file and can be written or read about 10 times faster. Interested readers will find references to PACT documentation later in this manual.

Before plunging into descriptions of the commands and variables for ULTRA II, a brief tutorial is given.

An ULTRA II Tutorial

This section gives a tutorial introduction to ULTRA II. A sample session is run which highlights the basic ULTRA commands.

NOTE: In ULTRA commands, spaces are used to delimit items on the input line. More precisely items on a command line are either space delimited, are preceded by a left parenthesis if the first item in a list, or terminated by a right parenthesis if the last item in a list. Semicolons may be used to stack multiple commands on a single interactive input line. In interactive mode, ranges of curve numbers or data-id’s may be indicated using colon notation. For example,

a:f
or

5:9
This notation is shorthand for the thru procedure.

To start up ULTRA II essarilyray *arr; {object *op; op = SS_mk_object(arr, G_NUM_ARRAY, SELF_EV, arr->type); op->print = _wr_gnum_array; op->release = _rl_gnum_array;; return(op); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* ARRAYP - function version of ARRAYP macro * - this is the function mentioned in step #5 */ object *arrayp(obj) object *obj; {return(ARRAYP(obj) ? SS_t : SS_f); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* MK_ARRAY - allocate and return a array * - form: (make-array ) * - this is a step #6 function */ static object *mk_array(argl) object *argl; {array *arr; long size, bpi; char *type, ltype[MAXLINE]; type = NULL; size = 0L; SS_args(argl, SC_STRING_I, &type, SC_LONG_I, &size, SC_LONG_I, &bpi, 0); arr = MAKE(array); sprintf(ltype, "%s *", type); arr->type = SC_strsave(ltype); arr->length = size; arr->data = (byte *) MAKE_N(char, size*bpi); return(_mk_array(arr)); /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/ /* INSTALL_ARRAY_FUNCS - install some array extensions to SX * - this is step #7 */ void install_array_funcs() { /* install the fundamental array operations */ SS_install("array?", "Return #t if the object is a numeric array, and #f otherwise", SS_sargs, arrayp, SS_PR_PROC); SS_install("make-array", "Allocate and return an array of the specified type and size", SS_nargs, mk_array, SS_PR_PROC); /* suggestions for other SCHEME level operations with arrays */ #if 0 SS_install("list->array", "Return a numeric array built from a list of numbers", SS_nargs, list_array, SS_PR_PROC); SS_install("array->list", "Return a list of numbers built from a numeric array", SS_sargs, array_list, SS_PR_PROC); SS_install("resize-array", "Reallocate the given array to the specified size", SS_nargs, resz_array, SS_PR_PROC); SS_install("array-ref", "Reference the nth element of an array", SS_nargs, array_ref, SS_PR_PROC); SS_install("array-set!", "Set the nth element of an array", SS_nargs, array_set, SS_PR_PROC); SS_install("array-length", "Return the length of the given numeric array", SS_sargs, num_arr_len, SS_PR_PROC); #endif return; /*-----------------------------------------------------------------*/ /*-----------------------------------------------------------------*/


Compiling and Loading

To compile your C programs you must use one or the other (not both) of the following

#include <scheme.h>

#include <sx.h>

in the source files which deal with the interpreter.

To link your application you must use the following libraries in the order specified. For SCHEME only programs use:

-lscheme -lppc -lpdb -lpml -lscore [-lm ...]
For SX programs use:

-lsx -lscheme -lpanacea -lpgs [-lX11] -lppc -lpdb -lpml -lscore [-lm ...]

Although this is expressed as if for a UNIX linker, the order would be the same for any system with a single pass linker. The items in [] are optional or system dependent.

Each system has different naming conventions for its libraries and the reader is assumed to understand the appropriate naming conventions as well as knowing how to tell the linker to find the installed PACT libraries on each system that they use.

Calling Interpreted Routines from Compiled Routines

The only real trick to having a compiled routine call an interpreted one is to map the compiled parameters or arguments into a representation which the evaluator is able to use. Naturally, that means making a list of SCHEME objects out of the arguments and applying the interpreted function to them. The interpreted function can be specified by name so that part it easy. To make the correct SCHEME objects (referred to simply as objects from now on - sorry but the LISP folks co-opted that term long before the OOP folks) from the compiled variables, you need only give the integer object type designation (see the previous section) and a pointer to the variable for each argument. The function SS_call_scheme does the rest. Specifically, it builds a list of objects from the supplied information, looks up the named procedure, applies it to the list of arguments, and returns the value which the interpreted routine returns. The important part to note here is that SS_call_scheme returns a SCHEME object! Note also the similarity between SS_call_scheme and SS_args. These two functions are complementary and realize the majority of the run time interface between interpreted and compiled functions.

Here is an example continuing the array example of the last section:


    object *rv;
    char *type;
    int n, bpi;

/* invoke the SCHEME level function create-array
 * this is the same as (create-array "float" 10 4)
 */
    type = "float";
    n    = 10;
    bpi  = sizeof(float);
    rv = SS_call_scheme("create-array",
                        SC_STRING_I, type,
                        SC_INTEGER_I, &n,
                        SC_INTEGER_I, &bpi,
                        0);
                        .
                        .
                        .
    long length;
    char *ntype;
    double *data;

    length = ARRAY_LENGTH(rv);
    ntype  = ARRAY_TYPE(rv);
    data   = ARRAY_DATA(rv);


The SCHEME level use of this example is limited only by the number of functions defined so far to manipulate such objects. Here is a fragment of SCHEME code showing their use:


 (let* ((x (make-array "double" 10 8)))

     (if (array? x)

          (printf nil "We have an array: %s\n" x)))

       
If we assume the existence of the functions alluded to in install_array_funcs we can show a more useful example:



(let* ((x (make-array "double" 10 8)))

    (array-set! x 5 15.34)

    (examine x 5)

       

(define (examine x n)

   (cond ((and (pair? x) (< n (length x)))

          (printf nil "List element %d = %s\n" n (list-ref x n)))

         ((and (array? x) (< n (array-length x)))

          (printf nil "Array element %d = %s\n" n (array-ref x n)))))




Related Documents

SX is one part of PACT, a set of tools for portable code development and visualization. Users of SX may be interested in the other parts of PACT especially since the various aspects of SX are derived from PACT. That is the graphics is handled by PGS; and the binary file handling is done by PDBLib.

The list of PACT Documents is:

PACT User’s GuideUCRL-MA-112087
SCORE User’s ManualUCRL-MA-108976 Rev.1
PPC User’s ManualUCRL-MA-108964 Rev.1
PML User’s ManualUCRL-MA-108965 Rev.1
PDBLib User’s ManualM-270 Rev.2
PGS User’s ManualUCRL-MA-108966 Rev.1
PANACEA User’s ManualM-276 Rev.2
ULTRA II User’s ManualUCRL-MA-108967 Rev.1
PDBDiff User’s ManualUCRL-MA-108975 Rev.1
PDBView User’s ManualUCRL-MA-108968 Rev.1
SX User’s ManualUCRL-MA-112315Current Document

Last modified: Fri Jul 30 09:25:58 PDT 1999

Modified by: rodrigues2@llnl.gov

./usr/share/doc/pact/html/ultra.html0100644000000000000000000042714306755524243016331 0ustar rootroot ULTRA Document

ULTRA DOCUMENT

Stewart A. Brown