User Defined Operations Dialog
==============================
1. Introduction
---------------
This window allows you to operate on a spectrum with a program of your
own. Motplot sets up a program specified in this window so that it can
read a spectrum from stdin ( unit 5 in FORTRAN ) and write it to stdout
( unit 6 in FORTRAN ). The files $MOTPLOTHELPDIR/userop.c and
$MOTPLOTHELPDIR/userop.f contain template C and FORTRAN operations.
These programs are also listed at the end of this help information.
2. Description
--------------
The window consists of two TEXT AREAS for the spectrum ( or spectra ) to
be operated on and for the name of the program to use. There are three
BUTTONS, "Operate" which carries out the operation, "Cancel" which aborts
the operation and "Help" which displays this help.
3. Operation
------------
Make your program from one of the templates and compile it. Type the
number(s) of the spectrum on which you wish to operate into the first
text area. ( You may select from the spectrum list instead as with all
Motplot dialogs ). Type the name of your program into the second text
area. If your program needs any command line arguments type these into
the text area too, just as you would when running a program outside of
Motplot. Operate the "Operate" button and the processed spectrum will
appear in the spectrum list.
If you have any difficulties with this facility please contact Paul
Stephenson as soon as possible. Your input is needed to make it easy
to use.
NB IMPORTANT
------------
If your program does not supply enough information to Motplot then
Motplot will crash when you try to access the newly created spectrum.
(eg. If your program sends 10 as the number of points, but actually sends
less than 10 points of data Motplot wiil appear ok until the spectrum is
accessed).
This problem is being addressed for a future release.
Example Programs
----------------
FORTRAN
-------
-----------------------------------------------------------
*
* This is a template for a program to be used as a user *
* defined operation. Motplot arranges for this program to *
* be run with any arguments typed after it in the User *
* defined operation window. Motplot also arranges that it *
* can read from unit 5 and write to unit 6 *
*
* NB VERY IMPORTANT - do not use units 5 and 6 within *
* your part of the program. If you want to report on what *
* is happening open a file on another unit. If you want *
* input then using command line arguments within the User *
* defined operation window will work best. If you MUST *
* get terminal input then OPEN another file *
*
PROGRAM USEROP
*
* You may wish to increase this parameter
*
PARAMETER(MAXNP=1000)
*
* Do not change these declarations
*
REAL OLDX(MAXNP)
REAL OLDY(MAXNP)
REAL NEWX(MAXNP)
REAL NEWY(MAXNP)
INTEGER OLDNP
INTEGER NEWNP
INTEGER I
*
*
*
************************************************************
*
* Section 1
* =========
*
* DO NOT MODIFY THIS SECTION which reads the old values from
* motplot
*
READ(5,*)OLDNP
IF( OLDNP .GT. MAXNP ) OLDNP = MAXNP
DO 10 I = 1, OLDNP
READ(5,*)OLDX(I),OLDY(I)
10 CONTINUE
*
*
************************************************************
*
* Section 2
* =========
*
* Put your own code to generate a new spectrum here. This
* example makes the new spectrum equal to the old one
*
NEWNP = OLDNP
DO 20 I = 1, NEWNP
NEWX(I) = OLDX(I)
NEWY(I) = OLDY(I)+10.0
20 CONTINUE
*
************************************************************
*
* Section 3
* =========
*
* DO NOT MODIFY THIS SECTION which writes the new values to
* motplot
*
WRITE(6,*)NEWNP
DO 30 I = 1, NEWNP
WRITE(6,*)NEWX(I),NEWY(I)
30 CONTINUE
*
STOP
END
-----------------------------------------------------------
C
-
-----------------------------------------------------------
/***********************************************************/
/***********************************************************/
/* */
/* userop.c */
/* */
/***********************************************************/
/***********************************************************/
/* This is a template for a program to be used as a user */
/* defined operation. Motplot arranges for this program to */
/* be run with any arguments typed after it in the User */
/* defined operation window. Motplot also arranges that it */
/* can read from the standard input and write to the */
/* standard output. */
/* NB VERY IMPORTANT - do not use scanf and printf within */
/* your part of the program. If you want to report on what */
/* is happening using fprintf and write to stderr. If you */
/* want input using command line arguments within the User */
/* defined operation window will work best. If you MUST */
/* get terminal input then use fopen to open another FILE */
#include
main(argc, argv)
int argc;
char **argv;
{
/* DO NOT change the following declarations: */
int oldnpoints;
float *oldxvalues;
float *oldyvalues;
int newnpoints;
float *newxvalues;
float *newyvalues;
int i;
/* put your own declarations here: */
/****************************************************************/
/* Section 1 */
/* ========= */
/* This section reads in the old spectrum from motplot */
/* DO NOT MODIFY IT */
scanf("%d\n",&oldnpoints);
oldxvalues = ( float * ) malloc( oldnpoints * sizeof( float ) );
oldyvalues = ( float * ) malloc( oldnpoints * sizeof( float ) );
for ( i=0; i