Reading a Spectrum from a Pipe (i.e. the output of another program)


This window allows you to read a spectrum into motplot as the output of another program. You should type into the text area a command to run a program as you would type it on the command line. Then operate the "Run" button by clicking the left mouse button on it or by pressing the "Return" key. Motplot sets up communication between itself and the command that you specify. The command should write to standard output. This means that C programs should write to "stdout" and FORTRAN programs should write to unit 6. The output of the program should be:

Some examples are given at the end of this help file. It is likely that in future versions of motplot you will be able to specify other parts of the spectrum, its name for example. At present however all spectra produced in this way are given the name "Output of script" where script is replaced by the command you typed in the text area.

IMPORTANT

Motplot is able to detect many errors in the output of the command. The most important that it cannot detect causes the program to wait indefinetely.

If your command is a valid command but produces no output and does not terminate because it is itself waiting for input ( e.g. "cat" ) then the process running it will wait for ever.

This problem will be addressed in a future release.

Example 1

A C shell script which produces squares of 1 to 10 in a form suitable for use here:

#!/bin/csh

#

# write out the number of points

echo 10

#

# set up a loop from 1 to 10

@ x = 1

while ( $x <= 10 )

#

# at each point set y equal to x*x

# and write out x and y

@ y = $x * $x

echo $i $y

#

# increment the loop counter

@ i++

end

#

Example 2

A C program to produce the same output as Example 1.

main()

{

int i;

float x;

float y;

printf("10\n");

for ( i=1; i<=10; i++ )

{

x = (float) i;

y = x * x;

printf("%f %f \n", x, y )

;

}

}

Example 3

A FORTRAN program to produce the same output as Examples 1 and 2

PROGRAM TESTF

*

INTEGER I

INTEGER

J

REAL X

REAL Y

*

I = 10

WRITE(6,*) I

*

DO 10 J = 1, 10

X = J

Y = X * X

WRITE(6,*) X, Y

10 CONTINUE

*

STOP

END