Frances Bauer writes:
> One of our users would like to use NCAR interactively. He wants to watch
> the calculation and corresponding plot as it develops and be able to
> interact with the program. Can this be done with NCAR and how? Where
> in the Manuals can we find information?
I'm not sure where all the information is to be found, but the attached
example may be of interest. (I just threw it together, so there may be
errors.) The idea is to have an interactive tool that will graph the
function F(X) = A*X**5 + B*X**4 + C*X**3 + D*X**2 + E*X + F for different
values of A, B, C, D, E, and F and over different ranges of X. (This is
probably not quite what Frances had in mind, but some parts of the example
may apply.) The program is compiled and executed with a
ncargf77 program.f ; a.out
It brings up an X window in which to display the graph. Commands are
typed in the original window to get help, to quit, to print current
values of the coefficients, to change coefficients, and so on.
The main thing I don't know how to do easily is to capture a user-generated
interrupt, which would be useful for the sort of thing I envision Frances
wanting to do.
PROGRAM TESTIT
C
C Define some data arrays to use.
C
DIMENSION XDAT(101),YDAT(101)
C
C Define default minimum and maximum values of X.
C
DATA XMIN,XMAX / 0.,1. /
C
C Define default values of coefficients in the displayed function.
C
DATA A,B,C,D,E,F / 6*0. /
C
C Define the function to be displayed.
C
FUNC(X)=A*X**5+B*X**4+C*X**3+D*X**2+E*X+F
C
C Open an X workstation.
C
CALL GOPKS (6, ISZDM)
CALL GOPWK (2,0,8)
CALL GACWK (2)
C
C Turn off frame advances by the AUTOGRAPH routine EZXY.
C
CALL AGSETI ('FRAME.',2)
C
C Clear the workstation.
C
101 CALL GCLRWK(2,1)
C
C Generate data and draw a picture.
C
DO 102 I=1,101
XDAT(I)=XMIN+REAL(I-1)*((XMAX-XMIN)/100.)
YDAT(I)=FUNC(XDAT(I))
102 CONTINUE
C
CALL EZXY (XDAT,YDAT,101,'TEST DISPLAY')
C
C Update the workstation.
C
CALL GUWK(2,0)
C
C Read a user command.
C
103 PRINT * , ' '
PRINT * , 'Enter a two-character command (HH for help, QQ to qui
+t) and a real number:'
C
READ (*,'(A2,E20.0)') CTMP,RVAL
C
C Do what the command implies.
C
IF (CTMP.EQ.'HH'.OR.CTMP.EQ.'hh') THEN
PRINT * , ' '
PRINT * , 'You asked for help. Available commands are as foll
+ows:'
PRINT * , ' '
PRINT * , ' Use HH for help.'
PRINT * , ' '
PRINT * , ' Use QQ to quit.'
PRINT * , ' '
PRINT * , ' Use PC to print values of coefficients.'
PRINT * , ' '
PRINT * , ' Use AA, BB, CC, DD, EE, or FF to change coefficie
+nts.'
PRINT * , ' '
PRINT * , ' Use XL and XR to change the range of X values use
+d.'
ELSE IF (CTMP.EQ.'QQ'.OR.CTMP.EQ.'qq') THEN
PRINT * , ' '
PRINT * , ' Quitting.'
GO TO 104
ELSE IF (CTMP.EQ.'PC'.OR.CTMP.EQ.'pc') THEN
PRINT * , ' '
PRINT * , ' Values of coefficients are as follows:'
PRINT * , ' '
PRINT * , ' A = ',A
PRINT * , ' B = ',B
PRINT * , ' C = ',C
PRINT * , ' D = ',D
PRINT * , ' E = ',E
PRINT * , ' F = ',F
ELSE IF (CTMP.EQ.'AA'.OR.CTMP.EQ.'aa') THEN
PRINT * , ' '
PRINT * , ' Changing the value of the coefficient A to ',RVAL
A=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'BB'.OR.CTMP.EQ.'bb') THEN
PRINT * , ' '
PRINT * , ' Changing the value of the coefficient B to ',RVAL
B=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'CC'.OR.CTMP.EQ.'cc') THEN
PRINT * , ' '
PRINT * , ' Changing the value of the coefficient C to ',RVAL
C=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'DD'.OR.CTMP.EQ.'dd') THEN
PRINT * , ' '
PRINT * , ' Changing the value of the coefficient D to ',RVAL
D=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'EE'.OR.CTMP.EQ.'ee') THEN
PRINT * , ' '
PRINT * , ' Changing the value of the coefficient E to ',RVAL
E=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'FF'.OR.CTMP.EQ.'ff') THEN
PRINT * , ' '
PRINT * , ' Changing the value of the coefficient F to ',RVAL
F=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'XL'.OR.CTMP.EQ.'xl') THEN
PRINT * , ' '
PRINT * , ' Changing the left X to ',RVAL
XMIN=RVAL
GO TO 101
ELSE IF (CTMP.EQ.'XR'.OR.CTMP.EQ.'xr') THEN
PRINT * , ' '
PRINT * , ' Changing the right X to ',RVAL
XMAX=RVAL
GO TO 101
ELSE
PRINT * , ' '
PRINT * , 'Huh? (Command not recognized.)'
END IF
C
GO TO 103
C
C Close the X workstation.
C
104 CALL GDAWK (2)
CALL GCLWK (2)
CALL GCLKS
C
C Done.
C
STOP
C
END
This archive was generated by hypermail 2b29 : Wed Jun 28 2000 - 09:45:35 MDT