fv5.5/tcltk/ 0000755 0002207 0000036 00000000000 13224715144 011641 5 ustar birby lhea fv5.5/tcltk/plt/ 0000755 0002207 0000036 00000000000 13224715127 012441 5 ustar birby lhea fv5.5/tcltk/plt/Makefile 0000644 0002207 0000036 00000001163 13224715127 014102 0 ustar birby lhea HD_COMPONENT_NAME = tcltk
HD_COMPONENT_VERS =
HD_LIBRARY_ROOT = plt
HD_LIB_STYLE = ${HD_LIB_STYLE_F77}
HD_LIBRARY_SRC_f = actwin.f akima.f akinte.f codsub.f cram.f \
curfit.f dscale.f fit.f fitit.f gamma.f gthelp.f \
hdecod.f ifgrp.f isact.f moment.f pgdev.f pgplot.f \
plconb.f ploger.f pltcct.f pltcur.f plt.f plthis.f \
pltlab.f pltskp.f pltsub.f pltxc.f ptbuf.f rdqdp.f \
rescal.f set_pgdev.f spline.f weight.f wrqdat.f \
wrtcol.f wrtcon.f wrtima.f yorn.f
HD_FFLAGS = ${HD_STD_FFLAGS}
HD_INSTALL_LIBRARIES = ${HD_LIBRARY_ROOT}
HD_INSTALL_HELP = plt.hlp
include ${HD_STD_MAKEFILE}
fv5.5/tcltk/plt/actwin.f 0000644 0002207 0000036 00000001735 13224715127 014103 0 ustar birby lhea SUBROUTINE ACTWIN(Ipwin, Ngroup, Mxwin, Iactw)
INTEGER Ngroup, Mxwin
INTEGER Ipwin(*), Iactw(*)
C---
C Runs throught the Ipwin array and returns 1 if ICWIN is currently
C active, and 0 otherwise
C---
C Ipwin I Array telling which window each group is to appear.
C Ngroup I Number of plot groups
C Mxwin I Number of windows to consider
C Iactw O =1 is window contains something to be plotted, =0 otherwise.
C---
C 1992-Apr-14 - New routine [AFT]
C---
INTEGER ig, iw
C---
C Scan through all windows in window list
DO 190 iw=1,Mxwin
C If any groups being plotted in window, set active window flag and jump
C to next window.
DO ig=1,Ngroup
IF ( Ipwin(ig).EQ.iw ) THEN
Iactw(iw) = 1
GOTO 190
END IF
END DO
C No groups, contour plots or images are being plotted in current window,
C so it must be inactive.
Iactw(iw) = 0
190 CONTINUE
RETURN
END
fv5.5/tcltk/plt/akima.f 0000644 0002207 0000036 00000025421 13224715127 013676 0 ustar birby lhea C--- PLT user model AKIMA.
C---
SUBROUTINE AKLIM(PAR, PLIM, NT, NTERM)
REAL PAR(*), PLIM(3,*)
INTEGER NT, NTERM
C---
C This routine must be called every time a parameter is changed.
C Calculates the coefficients and places them into the AKIMA
C common block for future reference.
C---
C PAR I/O Contain X and Y locations of the knots.
C PLIM I/O <0. means parameter is froozen.
C NT I
C NTERM I
C---
C AFT
C---
INTEGER MXKNOT
PARAMETER (MXKNOT=60)
REAL XDEL, YDEL, DIVIDE, YMIN, YMAX
INTEGER IND, IX
REAL RC
INTEGER NKNOT, IPER
COMMON /AKICMN/RC(3,MXKNOT), NKNOT, XDEL, YDEL, IPER
DATA DIVIDE/500./
C---
NKNOT=NTERM/2
IF(NKNOT.GT.MXKNOT) THEN
WRITE(*,101) MXKNOT
101 FORMAT(' AKLIM--Maximum number of knots is=',I6)
NKNOT=MXKNOT
END IF
IF ( NT.EQ.-1 ) THEN
NTERM=2*NKNOT
RETURN
END IF
XDEL=(PAR(NT+NKNOT-1)-PAR(NT))/(20.*NKNOT)
CALL AJUST(XDEL,PAR,PLIM,NT,NKNOT,YMIN,YMAX)
YDEL=(YMAX-YMIN)/DIVIDE
IF(YDEL.LE.0.) YDEL=1./DIVIDE
IPER=0
IND=NT+2*NKNOT-1
IX=NINT(-PLIM(1,IND))
IF(IX.EQ.NT+NKNOT .AND. PLIM(2,IND).EQ.1.) THEN
C- If first and last Y values are equal, force periodic boundary
C- condition.
IPER=1
END IF
CALL AKIMA(PAR(NT),RC,NKNOT,IPER)
RETURN
END
C*********
SUBROUTINE AJUST(XDEL, PAR, PLIM, NT, NKNOT, YMIN, YMAX)
REAL XDEL, PAR(*), PLIM(3,*), YMIN, YMAX
INTEGER NT, NKNOT
C---
C This routine adjusts the X-locations of the knots to enforce the
C condition that they monotonically increase in X.
C---
C XDEL I
C PAR I/O
C PLIM I
C NT I
C NKNOT I
C YMIN O
C YMAX O
C---
C AFT
C---
REAL TMP
INTEGER I, IAGAIN
C---
YMIN=PAR(NT+NKNOT)
YMAX=YMIN
DO 110 I=NT+NKNOT+1,NT+2*NKNOT-1
YMIN=MIN(YMIN,PAR(I))
YMAX=MAX(YMAX,PAR(I))
110 CONTINUE
C---
C- Assume the list can be sorted in a single pass. This should be
C- a good assumption for most cases. Under no condition should two
C- x-values be the same.
120 IAGAIN=0
DO 180 I=NT,NT+NKNOT-2
IF(PAR(I).EQ.PAR(I+1)) THEN
IF(PLIM(1,I).GE.0.) THEN
IF(PLIM(1,I+1).GE.0.) THEN
C Both free
PAR(i)=PAR(i)-XDEL/4.
PAR(i+1)=PAR(i+1)+XDEL/4.
ELSE
C 1st free, 2nd frozen
PAR(i)=PAR(i)-XDEL/2.
END IF
ELSE
IF(PLIM(1,I+1).GT.0) THEN
C 1st free, 2nd frozen
PAR(i+1)=PAR(i+1)+XDEL/2.
END IF
END IF
ELSE IF(PAR(I).GT.PAR(I+1)) THEN
IF(PLIM(1,I).GE.0.) THEN
IF(PLIM(1,I+1).GE.0.) THEN
C- Both free, swap positions
TMP=PAR(I)
PAR(I) =PAR(I+1)
PAR(I+1)=TMP
IF(I.GT.NT) THEN
C- If previous value messed up, set flag to go again.
IF(PAR(I-1).GE.PAR(I)) IAGAIN=1
END IF
ELSE
C- First free, second frozen, move first
PAR(I)=PAR(I+1)-XDEL/2.
END IF
ELSE
IF(PLIM(1,I+1).GT.0) THEN
C- First frozen, second free.
PAR(I+1)=PAR(I)+XDEL/2.
ELSE
C- Both frozen, this can only arise if user incorrectly enters data.
C- Avoid compounding the error.
IF(PAR(I).GE.PAR(I+1)) THEN
PAR(I+1)=PAR(I)+XDEL/2.
END IF
END IF
END IF
END IF
180 CONTINUE
IF(IAGAIN.NE.0) GOTO 120
RETURN
END
C*********
REAL FUNCTION FNAKIM(X, PAR)
REAL X, PAR(*)
C---
C Uses the coefficient array calculated in the call to AKLIM and
C returns the Akima function value.
C---
C X I
C PAR I
C---
C AFT
C---
INTEGER MXKNOT
PARAMETER (MXKNOT=60)
REAL FNXLIM, FNSPLN
REAL XT
REAL RC, XDEL, YDEL
INTEGER NKNOT, IPER
COMMON /AKICMN/RC(3,MXKNOT), NKNOT, XDEL, YDEL, IPER
C---
XT=FNXLIM(X,PAR(1),PAR(NKNOT),IPER)
FNAKIM=FNSPLN(XT,PAR,RC,NKNOT)
RETURN
END
C*********
REAL FUNCTION FNXLIM(X, XL, XH, IPER)
REAL X, XL, XH
INTEGER IPER
C---
C Forces X to lie in the range XL to XH.
C---
C X I/O
C XL I
C XH I
C IPER I <>0 Force function to be periodic
C---
C AFT
C---
REAL XT, RANGE
C---
XT=X
IF(IPER.NE.0) THEN
IF(XT.LT.XL) THEN
RANGE=XH-XL
XT=XT-RANGE*(INT((XT-XL)/RANGE)-1)
END IF
IF(XT.GT.XH) THEN
RANGE=XH-XL
XT=XT-RANGE* INT((XT-XL)/RANGE)
END IF
ELSE
XT=MIN(MAX(XL,XT),XH)
END IF
FNXLIM=XT
RETURN
END
C*********
SUBROUTINE AKIMA(PAR, RC, NKNOT, IPER)
INTEGER NKNOT, IPER
REAL PAR(2*NKNOT), RC(3,NKNOT)
C---
C Evaluate Akima coefficients.
C See J. of the Ass. for Comp. Mac., 1970, 17, 589.
C or PPC Journal, 1985, 12, no. 10, 11.
C---
C PAR
C C
C NKNOT
C---
C AFT
C---
REAL XDEL, RDIF1, RDIF2, RIM2, RIM1, RIP1
INTEGER I, IP1
C---
DO 120 I=1,NKNOT-1
XDEL=PAR(I+1)-PAR(I)
RC(3,I)=(PAR(NKNOT+I+1)-PAR(NKNOT+I))/XDEL
120 CONTINUE
IF(IPER.NE.0) THEN
RC(3,NKNOT)=RC(3,1)
ELSE
RC(3,NKNOT)=2.*RC(3,NKNOT-1)-RC(3,NKNOT-2)
END IF
DO 160 I=1,NKNOT
IF(IPER.NE.0) THEN
IF(I.LE.2) THEN
IF(I.EQ.1) THEN
RIM2=RC(3,NKNOT-2)
RIM1=RC(3,NKNOT-1)
ELSE
RIM2=RC(3,NKNOT-1)
RIM1=RC(3,1)
END IF
ELSE
RIM2=RC(3,I-2)
RIM1=RC(3,I-1)
END IF
IF(I.LT.NKNOT) THEN
RIP1=RC(3,I+1)
ELSE
RIP1=RC(3,2)
END IF
ELSE
IF(I.LE.2) THEN
XDEL=RC(3,1)-RC(3,2)
IF(I.EQ.1) THEN
RIM2=RC(3,1)+2.*XDEL
RIM1=RC(3,1)+ XDEL
ELSE
RIM2=RC(3,1)+ XDEL
RIM1=RC(3,1)
END IF
ELSE
RIM2=RC(3,I-2)
RIM1=RC(3,I-1)
END IF
IF(I.LT.NKNOT) THEN
RIP1=RC(3,I+1)
ELSE
RIP1=RC(3,NKNOT)+RC(3,NKNOT-1)-RC(3,NKNOT-2)
END IF
END IF
RDIF1=ABS(RIP1-RC(3,I))
RDIF2=ABS(RIM1-RIM2)
IF(RDIF1+RDIF2.GT.0.) THEN
RC(1,I)=(RDIF1*RIM1+RDIF2*RC(3,I))/(RDIF1+RDIF2)
ELSE
RC(1,I)=(RIP1+RC(3,I))/2.
END IF
160 CONTINUE
DO 180 I=1,NKNOT-1
IP1=I+1
XDEL=PAR(IP1)-PAR(I)
RC(2,I)=(3.*RC(3,I)-2.*RC(1,I)-RC(1,IP1))/XDEL
RC(3,I)=(RC(1,I)+RC(1,IP1)-2.*RC(3,I))/(XDEL*XDEL)
180 CONTINUE
RETURN
END
C*********
SUBROUTINE AKDERI(X, PAR, PLIM, DERIV, NT, NTERM)
REAL X, PAR(*), PLIM(3,*), DERIV(*)
INTEGER NT, NTERM
C---
C Calculate the derivitive of the AKIMA function with respect to
C the parameter values
C---
C X
C PAR
C PLIM
C DERIV
C NT
C NTERM
C---
C AFT
C---
INTEGER MXKNOT
PARAMETER (MXKNOT=60)
REAL FNXLIM, FNSPLN
REAL RTMP(3,MXKNOT), XT, YT, UFNY0, PXEND, PTMP
REAL RC, XDTMP, XDEL, YDEL
INTEGER J
INTEGER NKNOT, IPER
COMMON /AKICMN/RC(3,MXKNOT), NKNOT, XDEL, YDEL, IPER
C---
XT=FNXLIM(X,PAR(NT),PAR(NT+NKNOT-1),IPER)
UFNY0=FNSPLN(XT,PAR(NT),RC,NKNOT)
C- Do X locations
DO 130 J=NT,NT+NKNOT-2
IF(NINT(PLIM(1,J)).NE.-1) THEN
PTMP=PAR(J)
XDTMP=XDEL
PAR(J)=PAR(J)+XDTMP
IF(PAR(J).GT.PAR(J+1)) THEN
XDTMP=(PAR(J+1)-PAR(J))/20.
PAR(J)=PTMP+XDTMP
END IF
IF(J.EQ.NT) THEN
C Both endpoints move together.
PXEND=PAR(NT+NKNOT-1)
PAR(J)=PAR(J)+XDTMP
PAR(NT+NKNOT-1)=PAR(NT+NKNOT-1)+XDTMP
C Try moving Y knot along spline
C PYVAL=PAR(NT+NKNOT)
C PAR(NT+NKNOT)=FNSPLN(PAR(J),PAR(NT),RC,NKNOT)
C PAR(NT+2*NKNOT-1)=PAR(NT+NKNOT)
END IF
CALL AKIMA(PAR(NT),RTMP,NKNOT,IPER)
YT=FNSPLN(XT,PAR(NT),RTMP,NKNOT)
DERIV(J)=(YT-UFNY0)/XDTMP
PAR(J)=PTMP
IF(J.EQ.NT) THEN
PAR(NT+NKNOT-1)=PXEND
DERIV(NT+NKNOT-1)=0.
C Restore Y values
C PAR(NT+NKNOT)=PYVAL
C PAR(NT+2*NKNOT-1)=PAR(NT+NKNOT)
END IF
END IF
130 CONTINUE
C- Now do Y values.
DO 150 J=NT+NKNOT,NT+2*NKNOT-1
IF(NINT(PLIM(1,J)).NE.-1) THEN
PTMP=PAR(J)
PAR(J)=PAR(J)+YDEL
CALL AKIMA(PAR(NT),RTMP,NKNOT,IPER)
YT=FNSPLN(XT,PAR(NT),RTMP,NKNOT)
DERIV(J)=(YT-UFNY0)/YDEL
PAR(J)=PTMP
END IF
150 CONTINUE
RETURN
END
C*********
REAL FUNCTION FNSPLN(X, PAR, RC, NKNOT)
INTEGER NKNOT
REAL X, PAR(2*NKNOT), RC(3,NKNOT)
C---
C Evaluates a cubic SPLINE. Returns the value of the spline
C approximation given by:
C S= ((RC(3,J)*D+RC(2,J))*D+RC(1,J))*D+PAR(NKNOT+J)
C where PAR(J).LE.X .LT. PAR(J+1) and D=X-PAR(J).
C REMARKS:
C 1. The routine assumes that the abscissae of the NKNOT
C knots are ordered such that X(I) is less than
C X(I+1) for I=1,...,NKNOT-1.
C 2. The ordinate Y(NKNOT) is not used by the routine. For
C U(K) .GT. X(NKNOT-1), the value of the spline, S(K), is
C given by
C S(K)=((RC(3,NKNOT-1)*D+RC(2,NKNOT-1))*D+RC(1,NKNOT-1))*D+Y(NKNOT-1)
C where D=U(K)-X(NKNOT-1).
C
C---
C X I The abscissae of the point at which the cubic spline
C -is to be evaluated.
C PAR I PAR(1) to PAR(NKNOT) contains the abscissae of the
C -knots which must be ordered so that PAR(I).LT.PAR(I+1).
C -PAR(NKNOT+1) to PAR(2*NKNOT) contains the
C -ordinates (or function values) of the knots.
C RC I SPLINE coefficients. RC is an NKNOT-1 by 3 matrix.
C---
C AFT
C---
REAL D, DD
INTEGER I
DATA I/1/
C---
C- Find the proper interval
D=X-PAR(I)
C IF(D) 5,20,15
IF ( D.GT.0.0 ) GOTO 15
IF ( D.EQ.0.0 ) GOTO 20
C---
5 IF(I .EQ. 1) GOTO 20
I=I-1
D=X-PAR(I)
IF(D.GE.0) GOTO 20
GOTO 5
C---
10 I=I+1
D=DD
15 IF(I .GE. NKNOT) THEN
I=NKNOT-1
D=X-PAR(I)
GOTO 20
END IF
DD=X-PAR(I+1)
IF(DD .GE. 0.0) GOTO 10
C- Perform evaluation
20 FNSPLN=((RC(3,I)*D+RC(2,I))*D+RC(1,I))*D+PAR(NKNOT+I)
RETURN
END
fv5.5/tcltk/plt/akinte.f 0000644 0002207 0000036 00000012451 13224715127 014066 0 ustar birby lhea SUBROUTINE AKINTE(Xval, Y, Igroup, Iy0, Npts, iper, Init, Yval)
REAL Xval, Y(*), Yval
INTEGER igroup, Iy0, Npts, iper, Init
C---
C Interpolate a value using an Akima spline. This is an PLT internal
C routine.
C---
C Xval I The X position to interpolate
C Y I The data array
C Igroup I Used by pltxc to calculate the current X value.
C Iy0 I Y(Iy0+I) is the y-value of the Ith data point.
C Npts I The last data point in the fit range.
C iper I =0 not periodic, <>0 force periodic boundary condition.
C Init I/O <>0 force spline coef. to be recalcuated. Set to zero on exit.
C Yval O The interpolated Y position
C---
C 1991-Nov-20 - AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXDIM
PARAMETER (MXDIM=2)
C
REAL slope(-2:2), xt(MXDIM), x1(MXDIM)
REAL rc1(0:1), rc2, rc3
SAVE rc1, rc2, rc3
REAL dx, dd, rdif1, rdif2, rim2, rim1, rip1, sdel, xdel
INTEGER ip(-2:3)
SAVE ip
INTEGER i, itry, j, ndim, iyoff, iyof1
INTEGER inew, ie, is, iyof0
SAVE inew, ie, is, iyof0
C---
IF ( Init.NE.0 ) THEN
ip(0)=0
Init=0
DO i=1,Npts
CALL PLTXCC(Y, i, Igroup, xt, ndim, iyoff)
IF ( Y(Iy0+iyoff).NE.NO .AND. xt(1).NE.NO ) THEN
IS=I
GOTO 110
END IF
END DO
110 CONTINUE
DO i=Npts,1,-1
CALL PLTXCC(Y, i, Igroup, xt, ndim, iyoff)
IF ( Y(Iy0+iyoff).NE.NO .AND. xt(1).NE.NO ) THEN
ie=i
GOTO 120
END IF
END DO
120 CONTINUE
inew=is
END IF
C
C Find the proper interval
CALL PLTXCC(Y, inew, igroup, xt, ndim, iyoff)
dx = XVAL-xt(1)
C IF ( dx ) 130,200,150
IF ( dx.GT.0.0 ) GOTO 150
IF ( dx.EQ.0.0 ) GOTO 200
C---
C Search backwards until Y value<>NO and D becomes positive
130 CONTINUE
IF ( inew.EQ.is ) GOTO 200
inew = inew-1
CALL PLTXCC(Y, inew, igroup, xt, ndim, iyoff)
IF ( Y(Iy0+iyoff).EQ.NO .OR. xt(1).EQ.NO ) GOTO 130
dx = XVAL-xt(1)
IF ( dx.GE.0.0 ) GOTO 200
GOTO 130
C---
C Search forwards until Y value<>NO and next D is negative
150 itry=inew
160 IF ( itry+1.GE.ie ) GOTO 200
itry=itry+1
CALL PLTXCC(Y, itry, igroup, xt, ndim, iyoff)
IF ( Y(Iy0+iyoff).EQ.NO .OR. xt(1).EQ.NO ) GOTO 160
dd = XVAL-xt(1)
IF ( dd.LT.0.0 ) GOTO 200
dx = dd
inew=itry
GOTO 160
C---
200 CONTINUE
IF ( inew.NE.ip(0) ) THEN
C---
C Set up pointer array for periodic boundary condition. Add Npts before
C taking MOD to ensure positive result.
ip(-2)=MOD(Npts+inew-3,Npts)+1
ip(-1)=MOD(Npts+inew-2,Npts)+1
ip( 0)=inew
ip( 1)=MOD( inew ,Npts)+1
ip( 2)=MOD( inew+1,Npts)+1
ip( 3)=MOD( inew+2,Npts)+1
C---
C Remove any pointers to NO data values
DO i=1,3
240 CONTINUE
CALL PLTXCC(Y, ip(i), igroup, xt, ndim, iyoff)
IF ( Y(Iy0+iyoff).EQ.NO .OR. xt(1).EQ.NO ) THEN
DO J=I,3
ip(J)=MOD(ip(J),Npts)+1
END DO
IF(ip(3).LT.IE) GOTO 240
END IF
END DO
DO i=-1,-2,-1
260 CONTINUE
CALL PLTXCC(Y, ip(i), igroup, xt, ndim, iyoff)
IF ( Y(Iy0+iyoff).EQ.NO .OR. xt(1).EQ.NO ) THEN
DO J=I,-2,-1
ip(J)=MOD(Npts+ip(J)-2,Npts)+1
END DO
IF(ip(-2).GT.IS) GOTO 260
END IF
END DO
C
C Calculate slopes assuming periodic boundary condition.
DO i=-2,2
CALL PLTXCC(Y, ip(i), igroup, x1, ndim, iyoff)
CALL PLTXCC(Y, ip(i+1), igroup, xt, ndim, iyof1)
xdel=xt(1) - x1(1)
slope(I)=(Y(Iy0+iyof1)-Y(Iy0+iyoff))/xdel
END DO
C---
C If not periodic, then fix up ends if needed.
IF ( iper.EQ.0 ) THEN
IF ( ip(0).EQ.IS ) THEN
sdel=slope(0)-slope(1)
slope(-2)=slope(0)+2.*sdel
slope(-1)=slope(0)+ sdel
ELSE IF ( ip(0).EQ.IS+1 ) THEN
sdel=slope(-1)-slope(0)
slope(-2)=slope(-1)+ sdel
ELSE IF ( ip(0).EQ.IE-2 ) THEN
slope(2)=2*slope(1)-slope(0)
ELSE IF ( ip(0).EQ.IE-1 ) THEN
slope(1)=2*slope(0)-slope(-1)
slope(2)=slope(1)+slope(0)-slope(-1)
END IF
END IF
C---
C Calcuate parameters for Akima Spline.
DO i=0,1
rim2=slope(I-2)
rim1=slope(I-1)
rip1=slope(I+1)
rdif1=ABS(rip1-slope(I))
rdif2=ABS(rim1-rim2)
IF ( rdif1+rdif2.GT.0. ) THEN
rc1(i)=(rdif1*rim1+rdif2*slope(i))/(rdif1+rdif2)
ELSE
rc1(i)=(rip1+slope(I))/2.
END IF
END DO
C
CALL PLTXCC(Y, ip(0), Igroup, x1, ndim, iyof0)
CALL PLTXCC(Y, ip(1), Igroup, xt, ndim, iyoff)
xdel = xt(1) - x1(1)
rc2=(3.*slope(0)-2.*rc1(0)-rc1(1))/xdel
rc3=(rc1(0)+rc1(1)-2.*slope(0))/(xdel*xdel)
END IF
C---
C Calculate function value.
Yval=((rc3*dx+rc2)*dx+rc1(0))*dx+Y(Iy0+iyof0)
RETURN
END
fv5.5/tcltk/plt/codsub.f 0000644 0002207 0000036 00000121502 13224715127 014070 0 ustar birby lhea C Contains entry points for:
C CODFIL
C CODLIS
C CODTOK
C FNCOD
C FNCLOA
C CODADD SUB Add a word in the user dictionary
C CODCTI SUB Convert word to integer token
C CODITC SUB Convert integer token to word
C CODWOR SUB Find a word in the dictionary
C CODDER
C---
SUBROUTINE CODFIL(Cbuf, Lbuf, Kp, Nterm, Ier)
CHARACTER Cbuf*(*)
INTEGER Lbuf, Kp, Nterm, Ier
C Entry codfqc/codfsc
INTEGER Ichata
C---
C COmponent DEFination FILe.
C Reads a disk COD file into program memory.
C---
C Cbuf I
C Lbuf I
C Kp I/O
C Nterm O
C Ier O
C---
C 1989-Feb-13 - latest mod [AFT]
C---
REAL NO
PARAMETER (NO=-1.2E-34)
C-
REAL FNCLOA, FNCOD
INTEGER LENACT
C-
CHARACTER ctmp*256
CHARACTER ctok*132
CHARACTER clib*120
CHARACTER cdisk*12, cdir*12
REAL tmp, X, PAR(1)
INTEGER ichat
SAVE ichat
INTEGER icode, idelpc, idelsp, ientry, itry, itmp, ios
INTEGER llib, ltmp, ltok, lun, newt
DATA cdisk/'$XANADU'/, cdir/'xanlib/cod'/
DATA ichat/100/
C---
11 FORMAT(A)
C---
clib=' '
CALL PTEND(cdisk,cdir,clib)
llib=LENACT(clib)
CALL GETlun(lun)
newt=0
Ier=0
IF ( Cbuf(Kp+1:Kp+1).EQ.'$' ) Kp=Kp+1
ctok=Cbuf(Kp+1:)
C- First search the current directory for the file.
itry=0
100 CONTINUE
CALL XTEND(ctok,'cod')
CALL OPENWR(lun,ctok,'OLD',' ',' ',0,1,ios)
IF ( ios.NE.0 ) THEN
IF ( itry.EQ.0 ) THEN
C- Look in a standard library for file.
itry=1
ctok=clib(:llib)//Cbuf(Kp+1:)
CALL CONC(ctok(llib+1:))
GOTO 100
END IF
Ier=1
GOTO 910
END IF
C---
120 CONTINUE
READ(lun,11,ERR=500,END=500) ctmp
ltmp=LENACT(ctmp)
IF ( ichat.GT.0 ) WRITE(*,*) ctmp(:ltmp)
Kp=0
CALL ALF(ctmp,ltmp,Kp,ctok,ltok)
IF ( ctok(1:1).EQ.'!' ) GOTO 120
C---
Kp=0
150 CONTINUE
CALL ALF(ctmp,ltmp,Kp,ctok,ltok)
IF ( ltok.EQ.0 ) GOTO 120
CALL CODTOK(+1,ctok,ltok,icode,idelpc,idelsp,Ier)
IF ( Ier.NE.0 ) GOTO 900
IF ( idelpc.LE.0 ) GOTO 150
tmp=FNCOD(-1,icode,X,PAR,-1,Ier)
IF ( ctok(:ltok).EQ.':' ) THEN
tmp=FNCLOA(-7,ientry,itmp,0.)
END IF
IF ( icode.GE.4000 .AND. icode.LT.6000 ) THEN
C- Count parameters
newt=MAX(newt,icode-4000)
END IF
GOTO 150
C---
500 CONTINUE
Nterm=newt
ientry=ientry+1
tmp=FNCLOA(+4,ientry,0,0.)
IF ( ichat.GE.50 ) WRITE(*,*) 'Nterm=',newt
CLOSE(UNIT=lun)
CALL FRElun(lun)
RETURN
C---
C- Error return
900 CONTINUE
WRITE(*,*) 'CODFIL--Illegal token=',ctok(:ltok)
910 Nterm=0
CLOSE(UNIT=lun)
CALL FRElun(lun)
Ier=1
RETURN
C*********
ENTRY CODFSC(ichata)
ichat = Ichata
RETURN
C*********
ENTRY CODFQC(ichata)
Ichata = ichat
RETURN
END
C*********
SUBROUTINE CODLIS
C---
C List the current COD program in a FORTRAN style. Note this will
C only work for simple COD programs.
C---
C 1988-Nov-30 - [AFT]
C---
INTEGER MXSTAC
PARAMETER (MXSTAC=10)
C-
REAL FNCLOA
INTEGER LENACT
C-
CHARACTER cbuf*80, cstac(MXSTAC)*80
CHARACTER ctok*80
REAL tmp
INTEGER lstac(MXSTAC), isum(MXSTAC)
INTEGER icnt, icode, idelpc, idelsp, ier, indent, ipnt
INTEGER lbuf, lev, lpc, ltok
C---
icnt=0
lpc=1
C
90 CONTINUE
cstac(1)='Stack1'
lstac(1)=LENACT(cstac(1))
ipnt=1
indent=1
lev=0
100 CONTINUE
tmp=FNCLOA(-1,lpc,icode,tmp)
IF ( icode.EQ.0 ) THEN
C- END statement
GOTO 900
END IF
C- Get token form
CALL CODTOK(-1,ctok,ltok,icode,idelpc,idelsp,ier)
IF ( ctok(1:ltok).EQ.'IF' ) THEN
C- IF
IF ( ipnt.LE.0 ) GOTO 800
IF ( lstac(ipnt).GT.0 ) THEN
ctok=' '
WRITE(*,*) ctok(:indent),'IF ',cstac(ipnt)(:lstac(ipnt))
END IF
indent=indent+3
ipnt=ipnt-1
ELSE IF ( ctok(1:ltok).EQ.'ELSE' ) THEN
C- ELSE
IF ( ipnt.LE.0 ) GOTO 800
IF ( lstac(ipnt).GT.0 ) THEN
ctok=' '
WRITE(*,*) ctok(:indent),cstac(ipnt)(:lstac(ipnt))
END IF
WRITE(*,*) ctok(:indent-3),'ELSE'
ELSE IF ( ctok(1:ltok).EQ.'THEN' ) THEN
C- THEN
IF ( ipnt.LE.0 ) GOTO 800
IF ( lstac(ipnt).GT.0 ) THEN
ctok=' '
WRITE(*,*) ctok(:indent),cstac(ipnt)(:lstac(ipnt))
END IF
indent=indent-3
WRITE(*,*) ctok(:indent),'THEN'
ELSE IF ( ctok(1:ltok).EQ. ':' ) THEN
C- :
WRITE(*,*) ctok(:ltok)
ELSE IF ( ctok(1:ltok).EQ.';' ) THEN
C- ;
IF ( ipnt.EQ.0 ) THEN
WRITE(*,111)
111 FORMAT('; Return: ',A)
ELSE
WRITE(*,111) cstac(ipnt)(:lstac(ipnt))
END IF
WRITE(*,*)
lpc=lpc+idelpc
GOTO 90
ELSE IF ( ctok(1:2).EQ.'DR' .OR. ctok(1:ltok).EQ.'.' ) THEN
C- DRop .
IF ( ipnt.LE.0 ) GOTO 800
ipnt=ipnt-1
ELSE IF ( ctok(1:2).EQ.'DU' ) THEN
C- DUp
IF ( ipnt.LE.0 ) GOTO 800
cstac(ipnt+1)=cstac(ipnt)
lstac(ipnt+1)=lstac(ipnt)
isum(ipnt+1)=isum(ipnt)
ipnt=ipnt+1
ELSE IF ( ctok(1:2).EQ.'SW' ) THEN
C- SWap
IF ( ipnt.LE.1 ) GOTO 800
cbuf=cstac(ipnt)
cstac(ipnt)=cstac(ipnt-1)
cstac(ipnt-1)=cbuf
lbuf=lstac(ipnt)
lstac(ipnt)=lstac(ipnt-1)
lstac(ipnt-1)=lbuf
ELSE IF ( idelsp.EQ.1 ) THEN
C- Push number onto stack
IF ( ipnt.GE.MXSTAC ) GOTO 800
ipnt=ipnt+1
cstac(ipnt)=ctok(:ltok)
lstac(ipnt)=ltok
isum(ipnt)=0
ELSE IF ( idelsp.EQ.-1 ) THEN
C- Binary operation, first check that each of the two terms being
C- combined does not contain a + or - operator signaled by isum.NE.0.
C- If this is true then the term will need to be enclosed in '()'.
IF ( ipnt.LE.1 ) GOTO 800
IF ( isum(ipnt-1).GT.0 .OR.
: (ctok(1:1).EQ.'^' .AND. isum(ipnt-1).NE.0) ) THEN
cbuf='('//cstac(ipnt-1)(:lstac(ipnt-1))//')'
cstac(ipnt-1)=cbuf
lstac(ipnt-1)=lstac(ipnt-1)+2
END IF
IF ( isum(ipnt).GT.0 .OR.
: (ctok(1:1).EQ.'^' .AND. isum(ipnt).NE.0) ) THEN
cbuf='('//cstac(ipnt)(:lstac(ipnt))//')'
cstac(ipnt)=cbuf
lstac(ipnt)=lstac(ipnt)+2
END IF
C-
cbuf=cstac(ipnt-1)(:lstac(ipnt-1))//ctok(:ltok)//
: cstac(ipnt)(:lstac(ipnt))
ipnt=ipnt-1
lstac(ipnt)=LENACT(cbuf)
cstac(ipnt)=cbuf(:lstac(ipnt))
IF ( ctok(1:1).EQ.'+' .OR. ctok(1:1).EQ.'-' ) THEN
isum(ipnt)= 1
ELSE
isum(ipnt)=-1
END IF
ELSE
C- Uniary operator
IF ( ipnt.LE.0 ) GOTO 800
IF ( ctok(2:2).EQ.'+' .OR. ctok(2:2).EQ.'-' ) THEN
C- Special treatment for 1+, 1-, 2+ and 2-
cbuf='('//cstac(ipnt)(:lstac(ipnt))//')'//
: ctok(2:2)//ctok(1:1)
isum(ipnt)=1
ELSE
cbuf=ctok(:ltok)//'('//cstac(ipnt)(:lstac(ipnt))//')'
isum(ipnt)=0
END IF
cstac(ipnt)=cbuf
lstac(ipnt)=LENACT(cbuf)
END IF
C-
IF ( ipnt.GT.0 .AND. lstac(ipnt).GE.40 ) THEN
icnt=icnt+1
cbuf='T'
lbuf=1
CALL CRAMI(icnt,cbuf,lbuf)
WRITE(*,211) cbuf(:lbuf),cstac(ipnt)(:lstac(ipnt))
211 FORMAT(1X,A4,'==',A)
cstac(ipnt)=cbuf
lstac(ipnt)=lbuf
isum(ipnt)=0
END IF
C WRITE(*,*) I,ipnt,' ',cstac(ipnt)(:lstac(ipnt))
lpc=lpc+idelpc
GOTO 100
C---
800 CONTINUE
WRITE(*,*) 'CODLIS--Stack error.'
WRITE(*,*) cstac(ipnt)(:lstac(ipnt))
RETURN
C---
900 RETURN
END
C*********
SUBROUTINE CODTOK(Idir, Ctok, Ltok, Icode, Idelpc, Idelsp, Ier)
INTEGER Idir, Ltok, Icode, Idelsp, Idelpc, Ier
CHARACTER Ctok*(*)
C---
C If Idir.LT.0 then
C disassemble Icode into Ctok, Idelsp=change in stack
C Idir.GT.0
C compile Ctok(:Ltok) to Icode, Idelpc=number of program steps used.
C---
C 1989-Jan-29 - [AFT]
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXTOK, MXDEF
PARAMETER (MXTOK=67, MXDEF=16)
C
REAL FPNUM, FNCLOA
INTEGER ISNUM, LENACT
C
CHARACTER code(MXTOK)*4, cdef(MXDEF)*6
SAVE code, cdef
CHARACTER ctmp*132
REAL tmp, VALUE
INTEGER I, itmp, iend, LDEF, LOC
INTEGER INAME
SAVE INAME
INTEGER NDEL(MXTOK), IDEFS(MXDEF)
SAVE NDEL, IDEFS
C
DATA code/
: '+ ', '- ', '* ', '/ ', '^ ', 'DEPt', 'DRop',
: 'DUP', 'OVer', 'PICK', 'ROLL', 'ROT', 'SWap', '?Dup',
: 'ABS', 'NEG', '1/', 'PI', 'LN', 'EXP', 'LOG',
: 'ALog', 'SQrt', 'COS', 'SIN', 'TAN', 'ACos', 'ASin',
: 'ATan', 'A2tn', 'HCos', 'HSin', 'HTan', 'INT', 'NInt',
: 'MOD', '/MOD', 'TSIg', 'DTor', 'RTod', 'DMsd', 'DDms',
: 'ERFC', 'ERF', 'GAMM',
: '<', '=', '>', '0<', '0=', '0>', 'NOT',
: '.', '1+', '1-', '2+', '2-', 'MIN', 'MAX',
: 'STO', '+STO', 'RCL', '?', 'VAR', ':', ';',
: 'ABO'/
DATA NDEL/
: -1, -1, -1, -1, -1, 1, -1,
: 0, 1, 0, 0, 0, 0, 1,
: 0, 0, 0, 1, 0, 0, 0,
: 0, 0, 0, 0, 0, 0, 0,
: 0, -1, 0, 0, 0, 0, 0,
: -1, -1, -1, 0, 0, 0, 0,
: 0, 0, 0,
: -1, -1, -1, 0, 0, 0, 0,
: -1, 0, 0, 0, 0, -1, -1,
: -2, -2, 1, -1, 0, 0, 0,
: -999/
DATA cdef/
: 'X', 'IF', 'ELSE', 'THEN', 'FOR', 'LOOP', '+LOOP',
: 'I', 'J', 'LEAVE', 'BEGIN', 'UNTIL', 'WHILE','REPEAT',
: 'EXIT','Y'/
DATA IDEFS/
: 1, -1, 0, 0, -1, 0, -1,
: 1, 1, 0, 0, -1, -1, 0,
: 0, 1/
DATA INAME/0/
C---
Idelsp=0
Idelpc=1
Ier=0
IF ( Idir.LT.0 ) THEN
IF ( Icode.GT.6000 ) THEN
C- VAR's and : name.
CALL CODITC(Icode, Ctok, Ltok, Ier)
ELSE IF ( Icode.GT.4000 ) THEN
Ctok='P'
Ltok=1
itmp=Icode-4000
CALL CRAMI(itmp,Ctok,Ltok)
ELSE IF ( Icode.GT.2000 ) THEN
LOC=Icode-2000
tmp=FNCLOA(-2,LOC,0,VALUE)
Ltok=0
CALL CRAMF(VALUE,Ctok,Ltok)
ELSE IF ( 0.LT.Icode .AND. Icode.LE.MXTOK ) THEN
Ctok=code(Icode)
Ltok=LENACT(Ctok)
ELSE IF ( -MXDEF.LE.Icode .AND. Icode.LT.0 ) THEN
Ctok=cdef(-Icode)
Ltok=LENACT(Ctok)
ELSE
Ctok='END'
Ltok=3
END IF
ELSE
C- Compile the token
CALL UPC(Ctok)
Icode=0
DO I=1,MXTOK
IF ( Ctok(1:2).EQ.code(I)(1:2) ) THEN
C- First two characters match. Look for non-upper case to decide where
C- match should end.
iend = 4
itmp=ICHAR(code(I)(4:4))
IF ( itmp.LT.65 .OR. 90.LT.itmp ) iend=3
itmp=ICHAR(code(I)(3:3))
IF ( itmp.LT.65 .OR. 90.LT.itmp ) iend=2
itmp=ICHAR(code(I)(2:2))
IF ( itmp.LT.65 .OR. 90.LT.itmp ) iend=1
IF ( ltok.GE.iend ) THEN
C User entered at least minimum, match all the user typed.
ctmp = code(i)
CALL UPC(ctmp)
itmp = MIN(ltok,LENACT(ctmp))
IF ( Ctok(1:ltok).EQ.ctmp(:itmp) ) THEN
Icode=I
GOTO 300
END IF
END IF
END IF
END DO
C---
C- Now consider words that can only appear in programs.
IF ( Ltok.LT.LEN(Ctok) ) Ctok(Ltok+1:)=' '
DO I=1,MXDEF
LDEF=LENACT(cdef(I))
IF ( LDEF.EQ.Ltok ) THEN
C- Must be exact length
IF ( Ctok(:LDEF).EQ.cdef(I)(:LDEF) ) THEN
Icode=-I
GOTO 300
END IF
END IF
END DO
C---
C- Check for special cases (parameter or constant)
IF ( ISNUM(Ctok,Ltok).NE.0 ) THEN
C- A constant
tmp=FPNUM(Ctok,Ltok,Ier)
tmp=FNCLOA(2,0,Icode,tmp)
GOTO 300
END IF
IF ( Ctok(1:1).EQ.'P' ) THEN
IF ( ISNUM(Ctok(2:),Ltok-1).NE.0 ) THEN
C- Parameter number.
Ltok=Ltok-1
Icode=4000+MIN(NINT(FPNUM(Ctok(2:Ltok),Ltok,Ier)),100)
GOTO 300
END IF
END IF
C- Last chance, check user-defined dictionary word.
CALL CODCTI(Ctok, Ltok, Icode, Ier)
C---
C- Check for VARiable definations when compiling.
300 CONTINUE
IF ( Ier.EQ.0 ) THEN
C- Got a match, make sure not in VARiable defination.
IF ( INAME.NE.0 ) THEN
Idelpc=0
Icode=0
WRITE(*,*) 'CODTOK--Not allowed to redefine key word.'
Ier=1
END IF
C- Set flag to indicate that next token should go into dictionary.
IF ( Ctok(1:Ltok).EQ.'VAR' ) THEN
Idelpc=0
INAME=1
ELSE IF ( Ctok(1:Ltok).EQ.':' ) THEN
INAME=2
END IF
ELSE
C- No match
IF ( INAME.NE.0 ) THEN
C- We have a new dictionary word.
Idelpc=0
IF ( INAME.EQ.1 ) THEN
tmp=FNCLOA(+3,0,Icode,VALUE)
ELSE
tmp=FNCLOA(-6,itmp,Icode,VALUE)
Icode=8000+itmp
END IF
CALL CODADD(Ctok, Ltok, Icode, Ier)
INAME=0
END IF
END IF
END IF
C---
800 CONTINUE
IF ( Ier.EQ.0 ) THEN
IF ( Icode.EQ.-2 .OR. Icode.EQ.-3 .OR. Icode.EQ.-5 .OR.
: Icode.EQ.-6 .OR. Icode.EQ.-7 .OR. Icode.EQ.-13 ) Idelpc=2
IF ( Icode.GT.2000 .AND. Icode.LT.8000 ) THEN
C- 2000, 4000, 6000 (const, parameter, variable)
Idelsp=1
ELSE IF ( 0.LT.Icode .AND. Icode.LE.MXTOK ) THEN
Idelsp=NDEL(Icode)
ELSE IF ( -MXDEF.LE.Icode .AND. Icode.LT.0 ) THEN
Idelsp=IDEFS(-Icode)
ELSE
Idelsp=0
END IF
END IF
END
C*********
REAL FUNCTION FNCOD(ISTEP, INTER, X, PAR, NTERM, ier)
REAL X(2), PAR(*)
INTEGER ISTEP, INTER, NTERM, ier
C---
C On input:
C If ISTEP.LT.0 then execute the program step in INTER
C If ISTEP.EQ.0 then run program pointed at by IENTRY
C If ISTEP.GT.0 then take a single step
C On output
C ier= 0 for no error.
C ier= -1 if ISTEP<0 and INTER>0 and program is not compiling
C ier=100 when attempting to single step past final ;
C---
C ISTEP I Single step command
C X I The current value of X
C PAR(NTERM) I The parameter array
C---
C 1989-Jan-29 - Latest mod [AFT]
C---
REAL NO, INF
PARAMETER (NO=-1.2E-34, INF= 1.2E+34)
INTEGER MXPROG
PARAMETER (MXPROG=1500)
INTEGER MXSTAC, MXMEM, MXPROC
PARAMETER (MXSTAC=50, MXMEM=100, MXPROC=50)
C Note, ERF is an intinsic for g77.
REAL ERF, ERFC, GAMMA
C
CHARACTER ctmp*8
INTEGER*2 IPROG(MXPROG), IRET(MXSTAC), IPLOC(MXPROC)
SAVE IPROG, IRET, IPLOC
INTEGER IRPT, ISPT
SAVE IRPT, ISPT
INTEGER ltok
REAL STACK(MXSTAC), FMEM(MXMEM)
SAVE STACK, FMEM
C
REAL tmp, RSEC
INTEGER I, icnt, IDEG, IMIN, INEW, INSTR, Itmp
INTEGER ICOMP, idelpc, idelsp, IENTRY, IPC
SAVE ICOMP, idelpc, idelsp, IENTRY, IPC
INTEGER IPCNT, LCLOC, lpc, LVAR
SAVE IPCNT, LCLOC, lpc, LVAR
INTEGER J, lev
C Used in ENTRY points
REAL FNCLOA, FNPMAT
INTEGER IFUNC, ILOC, Icode, K, LOC, IPNUM
REAL VALUE
C
DATA IPC/1/, ICOMP/0/, lpc/0/, IENTRY/2/
C---
FNCOD=0.
IF ( ICOMP.NE.0 ) THEN
IF ( INTER.LT.0 ) THEN
GOTO( 100,6020,6030,6040,6020,6060,6060, 100, 100, 100,
: 100, 100, 100,6020, 100) -INTER
END IF
100 IF ( lpc.GE.MXPROG ) GOTO 950
lpc=lpc+1
IPROG(lpc)=INTER
C Number is MXTOK-1
IF ( INTER.EQ.66 ) ICOMP=0
RETURN
ELSE
IF ( ISTEP.LT.0 .AND. INTER.LT.0 ) THEN
C- Trying to interpret an instruction that can only be compiled.
ier=-1
RETURN
END IF
END IF
C---
IF ( ISTEP.LT.0 ) THEN
C- Run code step passed in INTER
IPC=IPC-1
INSTR=INTER
ELSE IF ( ISTEP.EQ.0 ) THEN
C- Reset and run entire program
IRPT=0
ISPT=0
IPC=IENTRY
INSTR=IPROG(IPC)
ELSE
C- Single step from current position
INSTR=IPROG(IPC)
END IF
C---
5 CONTINUE
GOTO(1010,1020,1030,1040,1050,1060,1070,1080,1090,1100,
: 1110,1120,1130,1140,1150,1160,1170,1180,1190,1200,
: 1210,1220,1230,1240,1250,1260,1270,1280,1290,1300,
: 1310,1320,1330,1340,1350,1360,1370,1380,1390,1400,
: 1410,1420,1430,1440,1450,1460,1470,1480,1490,1500,
: 1510,1520,1530,1540,1550,1560,1570,1580,1590,1600,
: 1610,1620,1630,1640,1650,1660,1670) INSTR
C-
IF ( INSTR.LT.0 ) THEN
GOTO(5010,5020,5030,5040,5050,5060,5070,5080,5090,5100,
: 5110,5120,5130,5140,5150,5160) -INSTR
GOTO 900
ELSE IF ( INSTR.GE.8000 ) THEN
C- GSB subroutine.
IF ( IRPT.GE.MXSTAC ) GOTO 920
IRPT=IRPT+1
IRET(IRPT)=IPC
Itmp=INSTR-8000
IF ( Itmp.GT.IPCNT ) GOTO 930
IPC=IPLOC(Itmp)
ELSE IF ( INSTR.GT.6000 ) THEN
C- Push variable address onto stack
IF ( ISPT.GE.MXSTAC ) GOTO 920
Itmp=INSTR-6000
ISPT=ISPT+1
STACK(ISPT)=Itmp
ELSE IF ( INSTR.GT.4000 ) THEN
C- Push a parameter onto the stack
IF ( ISPT.GE.MXSTAC ) GOTO 920
Itmp=INSTR-4000
ISPT=ISPT+1
STACK(ISPT)=PAR(Itmp)
ELSE IF ( INSTR.GE.2000 ) THEN
C- Push a constant onto the stack
IF ( ISPT.GE.MXSTAC ) GOTO 920
ISPT=ISPT+1
Itmp=INSTR-2000
STACK(ISPT)=FMEM(Itmp)
ELSE
GOTO 900
END IF
GOTO 880
C---
C- +
1010 IF ( ISPT.LE.1 ) GOTO 910
STACK(ISPT-1)=STACK(ISPT-1)+STACK(ISPT)
ISPT=ISPT-1
GOTO 880
C- -
1020 IF ( ISPT.LE.1 ) GOTO 910
STACK(ISPT-1)=STACK(ISPT-1)-STACK(ISPT)
ISPT=ISPT-1
GOTO 880
C- *
1030 IF ( ISPT.LE.1 ) GOTO 910
STACK(ISPT-1)=STACK(ISPT-1)*STACK(ISPT)
ISPT=ISPT-1
GOTO 880
C- /
1040 IF ( ISPT.LE.1 ) GOTO 910
IF ( STACK(ISPT).NE.0. ) THEN
STACK(ISPT-1)=STACK(ISPT-1)/STACK(ISPT)
ELSE
STACK(ISPT-1)=INF
END IF
ISPT=ISPT-1
GOTO 880
C- ^
1050 IF ( ISPT.LE.1 ) GOTO 910
IF ( STACK(ISPT-1).EQ.0.0 ) THEN
IF ( STACK(ISPT).EQ.0.0 ) GOTO 970
C zero to non-zero power.
STACK(ISPT-1)=0.0
ELSE
IF ( STACK(ISPT-1).LT.0. ) GOTO 970
tmp=STACK(ISPT)*LOG(STACK(ISPT-1))
IF ( tmp.LE.78. ) THEN
STACK(ISPT-1)=EXP(tmp)
ELSE
STACK(ISPT-1)=INF
END IF
END IF
ISPT=ISPT-1
GOTO 880
C- DEPth Return the current stack depth
1060 IF ( ISPT.GE.MXSTAC ) GOTO 920
STACK(ISPT+1)=ISPT
ISPT=ISPT+1
GOTO 880
C- DROP Lose top of stack
1070 IF ( ISPT.GE.1 ) ISPT=ISPT-1
GOTO 880
C- DUP Duplicate top of stack
1080 IF ( ISPT.LE.0 ) GOTO 910
IF ( ISPT.GE.MXSTAC ) GOTO 920
STACK(ISPT+1)=STACK(ISPT)
ISPT=ISPT+1
GOTO 880
C- OVER Duplicate second item from top
1090 IF ( ISPT.LT.2 ) GOTO 910
IF ( ISPT.GE.MXSTAC ) GOTO 920
STACK(ISPT+1)=STACK(ISPT-1)
ISPT=ISPT+1
GOTO 880
C- PICK Duplicate nth item on top of stack
1100 IF ( ISPT.LE.0 ) GOTO 910
Itmp=ISPT-NINT(STACK(ISPT))
IF ( Itmp.LE.0 .OR. Itmp.GE.ISPT ) GOTO 910
STACK(ISPT)=STACK(Itmp)
GOTO 880
C- ROLL Rotate nth item to top
1110 IF ( ISPT.LE.0 ) GOTO 910
Itmp=ISPT-NINT(STACK(ISPT))
ISPT=ISPT-1
IF ( Itmp.LE.0 .OR. Itmp.GE.ISPT ) GOTO 910
tmp=STACK(Itmp)
DO 1115 J=Itmp,ISPT-1
STACK(J)=STACK(J+1)
1115 CONTINUE
STACK(ISPT)=tmp
GOTO 880
C- ROTRotate third item to top
1120 IF ( ISPT.LT.3 ) GOTO 910
tmp=STACK(ISPT-2)
STACK(ISPT-2)=STACK(ISPT-1)
STACK(ISPT-1)=STACK(ISPT)
STACK(ISPT)=tmp
GOTO 880
C- SWAP Reverse top two stack items
1130 IF ( ISPT.LT.2 ) GOTO 910
tmp=STACK(ISPT-1)
STACK(ISPT-1)=STACK(ISPT)
STACK(ISPT)=tmp
GOTO 880
C- ?DUP Duplicate only if non-zero
1140 IF ( ISPT.LE.0 ) GOTO 910
IF ( STACK(ISPT).NE.0. ) THEN
IF ( ISPT.GE.MXSTAC ) GOTO 920
STACK(ISPT+1)=STACK(ISPT)
ISPT=ISPT+1
END IF
GOTO 880
C- ABS Absolute value
1150 STACK(ISPT)=ABS(STACK(ISPT))
GOTO 880
C- NEG Negate
1160 STACK(ISPT)=-STACK(ISPT)
GOTO 880
C- 1/ (reciprocal)
1170 IF (ABS(STACK(ISPT)) .LE. 1.0E-34) THEN
STACK(ISPT)=INF
ELSE
STACK(ISPT)=1.0/STACK(ISPT)
END IF
GOTO 880
C- PI (Pi)
1180 IF ( ISPT.GE.MXSTAC ) GOTO 920
STACK(ISPT+1)=ATAN2(0.0,-1.0)
ISPT=ISPT+1
GOTO 880
C- LN (natural log)
1190 IF ( STACK(ISPT).LE.0. ) GOTO 970
STACK(ISPT)=LOG(STACK(ISPT))
GOTO 880
C- EXP
1200 tmp=MAX(-80.,MIN(STACK(ISPT),80.))
STACK(ISPT)=EXP(tmp)
GOTO 880
C- LOG (common log)
1210 IF ( STACK(ISPT).LE.0. ) GOTO 970
STACK(ISPT)=LOG10(STACK(ISPT))
GOTO 880
C- ALOG (Anti common log)
1220 tmp=MAX(-34.,MIN(STACK(ISPT),34.))
STACK(ISPT)=10.0**tmp
GOTO 880
C- SQRT (square root)
1230 STACK(ISPT)=SQRT(ABS(STACK(ISPT)))
GOTO 880
C- COS
1240 STACK(ISPT)=COS(STACK(ISPT))
GOTO 880
C- SIN
1250 STACK(ISPT)=SIN(STACK(ISPT))
GOTO 880
C- TAN
1260 STACK(ISPT)=TAN(STACK(ISPT))
GOTO 880
C- ACOS (arc cosine)
1270 IF (ABS(STACK(ISPT)) .LE. 1.0) THEN
STACK(ISPT)=ACOS(STACK(ISPT))
ELSE
STACK(ISPT)=INF
END IF
GOTO 880
C- ASIN (arc sin)
1280 IF (ABS(STACK(ISPT)) .LE. 1.0) THEN
STACK(ISPT)=ASIN(STACK(ISPT))
ELSE
STACK(ISPT)=INF
END IF
GOTO 880
C- ATAN (arc tan)
1290 STACK(ISPT)=ATAN(STACK(ISPT))
GOTO 880
C- A2TN (arc tan 2 arguments)
1300 IF ( ISPT.LE.1 ) GOTO 910
IF ( STACK(ISPT).EQ.0.0 .AND. STACK(ISPT-1).EQ.0.0 ) THEN
STACK(ISPT-1)=0.0
ELSE
STACK(ISPT-1)=ATAN2(STACK(ISPT-1),STACK(ISPT))
END IF
ISPT=ISPT-1
GOTO 880
C- HCOS (Hyperbolic cosine)
1310 STACK(ISPT)=COSH(STACK(ISPT))
GOTO 880
C- HSIN (Hyperbolic sine)
1320 STACK(ISPT)=SINH(STACK(ISPT))
GOTO 880
C- HTAN (Hyperbolic tangent)
1330 STACK(ISPT)=TANH(STACK(ISPT))
GOTO 880
C- INT (Integer truncation)
1340 STACK(ISPT)=INT(STACK(ISPT))
GOTO 880
C- NINT (Nearest integer)
1350 STACK(ISPT)=NINT(STACK(ISPT))
GOTO 880
C- MOD (Remainder a1-a2*[a1/a2])
1360 IF ( ISPT.LE.1 ) GOTO 910
STACK(ISPT-1)=MOD(STACK(ISPT-1),STACK(ISPT))
ISPT=ISPT-1
GOTO 880
C- /MOD (Remainder a1-a2*[a1/a2], INT(a1/a2)
1370 IF ( ISPT.LE.1 ) GOTO 910
tmp=STACK(ISPT-1)
STACK(ISPT-1)=MOD(STACK(ISPT-1),STACK(ISPT))
STACK(ISPT)=INT(tmp/STACK(ISPT))
GOTO 880
C- TSig (Transfer of sign |a1| Sign a2)
1380 IF ( ISPT.LE.1 ) GOTO 910
STACK(ISPT-1)=SIGN(STACK(ISPT-1),STACK(ISPT))
ISPT=ISPT-1
GOTO 880
C- DTor (Convert degrees to radians)
1390 STACK(ISPT)=STACK(ISPT)*ATAN2(0.0,-1.0)/180.0
GOTO 880
C- RTod (Convert radians to degrees)
1400 STACK(ISPT)=STACK(ISPT)*180.0/ATAN2(0.0,-1.0)
GOTO 880
C- DMsd (Convert a number from DDDMMSS.S format to decimal degrees)
1410 IDEG=INT(STACK(ISPT)/1.0E4)
IMIN=INT((STACK(ISPT) - IDEG*1.0E4)/1.0E2)
RSEC=STACK(ISPT) - IDEG*1.0E4 - IMIN*1.0E2
STACK(ISPT)=IDEG + IMIN/60.0 + RSEC/3600.0
GOTO 880
C- DDms (Convert a number from decimal degrees to DDDMMSS.S format)
1420 IDEG=INT(STACK(ISPT))
IMIN=INT((STACK(ISPT) - IDEG)*60.0)
RSEC=STACK(ISPT) - IDEG - IMIN/60.0
STACK(ISPT)=IDEG*1.0E4 + IMIN*1.0E2 + RSEC
GOTO 880
C- ERFC
1430 CONTINUE
STACK(ISPT)=ERFC(STACK(ISPT))
GOTO 880
C- ERF
1440 CONTINUE
STACK(ISPT)=ERF(STACK(ISPT))
GOTO 880
C- Gamma
1450 CONTINUE
STACK(ISPT)=GAMMA(STACK(ISPT))
GOTO 880
C- <
1460 IF ( ISPT.LE.1 ) GOTO 910
IF ( STACK(ISPT-1).LT.STACK(ISPT) ) THEN
STACK(ISPT-1)=1.0
ELSE
STACK(ISPT-1)=0.0
END IF
ISPT=ISPT-1
GOTO 880
C- =
1470 IF ( ISPT.LE.1 ) GOTO 910
IF ( STACK(ISPT-1).EQ.STACK(ISPT) ) THEN
STACK(ISPT-1)=1.0
ELSE
STACK(ISPT-1)=0.0
END IF
ISPT=ISPT-1
GOTO 880
C- >
1480 IF ( ISPT.LE.1 ) GOTO 910
IF ( STACK(ISPT-1).GT.STACK(ISPT) ) THEN
STACK(ISPT-1)=1.0
ELSE
STACK(ISPT-1)=0.0
END IF
ISPT=ISPT-1
GOTO 880
C- 0<
1490 IF ( ISPT.LE.0 ) GOTO 910
IF ( STACK(ISPT).LT.0.0 ) THEN
STACK(ISPT)=1.0
ELSE
STACK(ISPT)=0.0
END IF
GOTO 880
C- 0=
1500 IF ( ISPT.LE.0 ) GOTO 910
IF ( STACK(ISPT).EQ.0.0 ) THEN
STACK(ISPT)=1.0
ELSE
STACK(ISPT)=0.0
END IF
GOTO 880
C- 0>
1510 IF ( ISPT.LE.0 ) GOTO 910
IF ( STACK(ISPT).GT.0.0 ) THEN
STACK(ISPT)=1.0
ELSE
STACK(ISPT)=0.0
END IF
GOTO 880
C- NOT
1520 IF ( ISPT.LE.0 ) GOTO 910
IF ( STACK(ISPT).EQ.0.0 ) THEN
STACK(ISPT)=1.0
ELSE
STACK(ISPT)=0.0
END IF
GOTO 880
C- . (Print the number at the top of the stack).
1530 IF ( ISPT.LE.0 ) GOTO 910
WRITE(*,*) STACK(ISPT)
ISPT=ISPT-1
GOTO 880
C- 1+
1540 IF ( ISPT.LE.0 ) GOTO 910
STACK(ISPT)=STACK(ISPT)+1.
GOTO 880
C- 1-
1550 IF ( ISPT.LE.0 ) GOTO 910
STACK(ISPT)=STACK(ISPT)-1.
GOTO 880
C- 2+
1560 IF ( ISPT.LE.0 ) GOTO 910
STACK(ISPT)=STACK(ISPT)+2.
GOTO 880
C- 2-
1570 IF ( ISPT.LE.0 ) GOTO 910
STACK(ISPT)=STACK(ISPT)-2.
GOTO 880
C- MIN
1580 IF ( ISPT.LE.1 ) GOTO 910
ISPT=ISPT-1
STACK(ISPT)=MIN(STACK(ISPT),STACK(ISPT+1))
GOTO 880
C- MAX
1590 IF ( ISPT.LE.1 ) GOTO 910
ISPT=ISPT-1
STACK(ISPT)=MAX(STACK(ISPT),STACK(ISPT+1))
GOTO 880
C- STO
1600 IF ( ISPT.LT.2 ) GOTO 910
Itmp=STACK(ISPT)
IF ( Itmp.LE.0 .OR. Itmp.GT.LVAR ) GOTO 940
FMEM(Itmp)=STACK(ISPT-1)
ISPT=ISPT-2
GOTO 880
C- +STO
1610 IF ( ISPT.LT.2 ) GOTO 910
Itmp=STACK(ISPT)
IF ( Itmp.LE.0 .OR. Itmp.GT.LVAR ) GOTO 940
FMEM(Itmp)=FMEM(Itmp)+STACK(ISPT-1)
ISPT=ISPT-2
GOTO 880
C- RCL
1620 IF ( ISPT.LE.0 ) GOTO 910
Itmp=STACK(ISPT)
IF ( Itmp.LE.0 .OR. Itmp.GT.LVAR ) GOTO 940
STACK(ISPT)=FMEM(Itmp)
GOTO 880
C- ?
1630 IF ( ISPT.LE.0 ) GOTO 910
Itmp=STACK(ISPT)
IF ( Itmp.LE.0 .OR. Itmp.GT.LVAR ) GOTO 940
WRITE(*,*) FMEM(Itmp)
ISPT=ISPT-1
GOTO 880
C- VAR (NOP)
1640 GOTO 880
C- : (Begin colon defination). Cannot execute when compiling or
C- running a program.
1650 IF ( ISTEP.GE.0 .OR. ICOMP.NE.0 ) GOTO 930
ICOMP=1
IF ( lpc.GE.MXPROG ) GOTO 950
lpc=lpc+1
IPROG(lpc)=INSTR
IF ( IPCNT.GE.MXPROC ) GOTO 920
IPCNT=IPCNT+1
IPLOC(IPCNT)=lpc
RETURN
C- ;
1660 IF ( ICOMP.NE.0 ) THEN
ICOMP=0
RETURN
ELSE
IF ( IRPT.LE.0 ) THEN
IF ( ISTEP.GT.0 ) ier=100
GOTO 900
END IF
IRPT=IRPT-1
IPC=IRET(IRPT+1)
END IF
GOTO 880
C- ABOrt
1670 IPC=1
IRPT=0
ISPT=0
FNCOD=NO
RETURN
C---
C- X (place current X into stack).
5010 IF ( ISPT.GE.MXSTAC ) GOTO 920
ISPT=ISPT+1
STACK(ISPT)=X(1)
GOTO 880
C- IF
5020 IF ( ISPT.LE.0 ) GOTO 910
ISPT=ISPT-1
IPC=IPC+1
IF ( STACK(ISPT+1).EQ.0.0 ) THEN
C- Not true, search for ELSE or THEN statement
IF ( IPROG(IPC).GT.0 ) THEN
IPC=IPROG(IPC)
C- Special treatment for ELSE.
IF ( IPROG(IPC).EQ.-3 ) IPC=IPC+1
GOTO 880
ELSE
GOTO 950
END IF
END IF
GOTO 880
6020 IF ( lpc.GE.MXPROG-1 ) GOTO 950
lpc=lpc+1
IPROG(lpc)=INTER
lpc=lpc+1
IPROG(lpc)=0
IRPT=IRPT+1
IRET(IRPT)=lpc
RETURN
C- ELSE, Assume correct nesting, search for closing THEN statement
5030 lev=0
IPC=IPC+1
IF ( IPROG(IPC).GT.0 ) THEN
IPC=IPROG(IPC)
GOTO 880
ELSE
GOTO 950
END IF
GOTO 880
6030 IF ( lpc.GE.MXPROG-1 ) GOTO 950
lpc=lpc+1
IPROG(lpc)=INTER
IF ( IRPT.LE.0 ) GOTO 950
IF ( IPROG(IRET(IRPT)).NE.0 ) GOTO 950
IPROG(IRET(IRPT))=lpc
lpc=lpc+1
IRET(IRPT)=lpc
RETURN
C- THEN, Assume correctly stuctured program.
5040 GOTO 880
6040 IF ( lpc.GE.MXPROG-1 ) GOTO 950
lpc=lpc+1
IPROG(lpc)=INTER
IF ( IRPT.LE.0 ) GOTO 950
IF ( IPROG(IRET(IRPT)).NE.0 ) GOTO 950
IPROG(IRET(IRPT))=lpc
IRPT=IRPT-1
RETURN
C- FOR
5050 IF ( IRPT+3.GT.MXSTAC ) GOTO 920
IF ( ISPT.LE.1 ) GOTO 910
IPC=IPC+1
IF ( IPROG(IPC).LE.0 ) GOTO 930
IRPT=IRPT+3
IRET(IRPT)=IPROG(IPC)
IRET(IRPT-1)=NINT(STACK(ISPT))
IRET(IRPT-2)=NINT(STACK(ISPT-1))
ISPT=ISPT-2
GOTO 880
C- LOOP
5060 IF ( IRPT.LT.3 ) GOTO 910
IRET(IRPT-1)=IRET(IRPT-1)+1
IF ( IRET(IRPT-1).LE.IRET(IRPT-2) ) THEN
IPC=IPROG(IPC+1)
ELSE
IRPT=IRPT-3
IPC=IPC+1
END IF
GOTO 880
C---
6060 IF ( lpc.GE.MXPROG-1 ) GOTO 950
lpc=lpc+1
IPROG(lpc)=INTER
lpc=lpc+1
IF ( IRPT.LE.0 ) GOTO 950
IF ( IPROG(IRET(IRPT)).NE.0 ) GOTO 950
IPROG(IRET(IRPT))=lpc
IPROG(lpc)=IRET(IRPT)
IRPT=IRPT-1
RETURN
C- +LOOP
5070 IF ( IRPT.LT.3 ) GOTO 910
IF ( ISPT.LE.0 ) GOTO 920
Itmp=IRET(IRPT-1)-IRET(IRPT-2)
IRET(IRPT-1)=IRET(IRPT-1)+NINT(STACK(ISPT))
INEW=IRET(IRPT-1)-IRET(IRPT-2)
ISPT=ISPT-1
IF ( (Itmp.LE.0 .AND. INEW.GT.0) .OR.
: (Itmp.GE.0 .AND. INEW.LT.0) ) THEN
C- terminate
IRPT=IRPT-3
IPC=IPC+1
ELSE
C- loop
IPC=IPROG(IPC+1)
END IF
GOTO 880
C- I
5080 IF ( IRPT.LT.3 ) GOTO 930
IF ( ISPT.GE.MXSTAC ) GOTO 920
ISPT=ISPT+1
Itmp=IRPT
5085 IF ( IPROG(IRET(Itmp)-1).EQ.-6 ) THEN
STACK(ISPT)=IRET(Itmp-1)
GOTO 880
END IF
Itmp=Itmp-1
IF ( Itmp.GT.0 ) GOTO 5085
GOTO 930
C- J
5090 IF ( IRPT.LT.6 ) GOTO 930
IF ( ISPT.GE.MXSTAC ) GOTO 920
ISPT=ISPT+1
Itmp=IRPT
icnt=0
5095 IF ( IPROG(IRET(Itmp)-1).EQ.-6 ) THEN
STACK(ISPT)=IRET(Itmp-1)
IF ( icnt.EQ.1 ) GOTO 880
icnt=icnt+1
Itmp=Itmp-2
END IF
Itmp=Itmp-1
IF ( Itmp.GT.0 ) GOTO 5095
GOTO 930
C- LEAVE
5100 IF ( IRPT.LT.3 ) GOTO 910
IPC=IRET(IRPT)
IRPT=IRPT-3
GOTO 880
C- BEGIN
5110 IF ( IRPT.GE.MXSTAC ) GOTO 920
IRPT=IRPT+1
IRET(IRPT)=IPC
GOTO 880
C- UNTIL
5120 IF ( ISPT.LE.0 ) GOTO 910
ISPT=ISPT-1
IF ( STACK(ISPT+1).NE.0.0 ) THEN
C- TRUE
IRPT=IRPT-1
ELSE
C- FALSE
IPC=IRET(IRPT)
END IF
GOTO 880
C- WHILE
5130 IF ( ISPT.LE.0 ) GOTO 910
ISPT=ISPT-1
IPC=IPC+1
IF ( STACK(ISPT+1).NE.0.0 ) THEN
C- TRUE
GOTO 880
ELSE
C- FALSE
IRPT=IRPT-1
IF ( IPROG(IPC).GT.0 ) THEN
IPC=IPROG(IPC)
GOTO 880
ELSE
lev=0
J=IPC+1
5135 CONTINUE
IF ( IPROG(J).EQ.0 ) GOTO 930
Itmp=IPROG(J)
CALL CODTOK(-1,ctmp,ltok,Itmp,idelpc,idelsp,ier)
IF ( IPROG(J).LT.0 ) THEN
IF ( ctmp(1:5).EQ.'BEGIN' ) THEN
C- Nested BEGIN
lev=lev+1
ELSE IF ( ctmp(1:5).EQ.'UNTIL' ) THEN
C- Nested UNTIL
lev=lev-1
ELSE IF ( ctmp(1:6).EQ.'REPEAT' ) THEN
C- REPEAT
IF ( lev.LE.0 ) THEN
IPROG(IPC)=J
IPC=J
GOTO 880
END IF
lev=lev-1
END IF
END IF
J=J+idelpc
IF ( J.LT.MXPROG ) GOTO 5135
END IF
END IF
GOTO 930
C- REPEAT
5140 IF ( IRPT.LE.0 ) GOTO 910
IPC=IRET(IRPT)
GOTO 880
C- EXIT
5150 DO 5155 I=IRPT,1,-1
IF ( IPROG(IRET(I)).GT.8000 ) THEN
IPC=IRET(I)
IRPT=I-1
GOTO 880
END IF
5155 CONTINUE
GOTO 930
C- Y (place current Y onto stack).
5160 IF ( ISPT.GE.MXSTAC ) GOTO 920
ISPT=ISPT+1
STACK(ISPT)=X(2)
GOTO 880
C---
880 CONTINUE
IPC=IPC+1
IF ( IPC.GT.0 ) INSTR=IPROG(IPC)
IF ( ISTEP.EQ.0 ) GOTO 5
C- Interactive, and a colon def
IF ( ISTEP.LT.0 .AND. IRPT.GT.0 ) GOTO 5
C---
900 IF ( ISPT.GT.0 ) THEN
FNCOD=STACK(ISPT)
ELSE
FNCOD=NO
END IF
RETURN
C---
910 WRITE(*,*) 'FNCOD--Stack empty'
ISPT=0
ier=1
GOTO 980
C---
920 WRITE(*,*) 'FNCOD--Stack overflow'
ier=2
GOTO 980
C---
930 WRITE(*,*) 'FNCOD--Error in structure or nesting'
ier=3
GOTO 980
C--
940 WRITE(*,*) 'FNCOD--Illegal variable address'
ier=4
GOTO 980
C---
950 WRITE(*,*) 'FNCOD--Out of program memory'
ier=5
GOTO 980
C---
C- Undefined operation
970 FNCOD=NO
STACK(ISPT)=NO
IF ( ISTEP.NE.0 ) WRITE(*,*) 'FNCOD--Math error.'
RETURN
C---
980 IF ( ISTEP.GE.0 ) THEN
WRITE(*,*) 'At line',IPC
END IF
FNCOD=NO
RETURN
C---
ENTRY FNCLOA(IFUNC, ILOC, Icode, VALUE)
FNCLOA = 0.
IF ( IFUNC.EQ.1 ) THEN
C- Complete reset.
DO 996 I=1,lpc
IPROG(I)=0
996 CONTINUE
ICOMP=0
IPCNT=0
LCLOC=MXMEM+1
LVAR=0
lpc=0
C- reset the dictionary.
CALL CODADD(' ',-1,0,Itmp)
ELSE IF ( IFUNC.EQ.2 ) THEN
C- Return the code value for a constant term VALUE.
Icode=0
DO 998 I=LCLOC,MXMEM
IF ( FMEM(I).EQ.VALUE ) THEN
Icode=2000+I
RETURN
END IF
998 CONTINUE
IF ( LCLOC.LE.LVAR ) STOP 'FNCOD--OUT OF FLOATING MEMORY.'
Itmp=LCLOC-1
C- Only allocate memory, if code is being compiled.
IF ( ICOMP.NE.0 ) LCLOC=LCLOC-1
FMEM(Itmp)=VALUE
Icode=2000+Itmp
ELSE IF ( IFUNC.EQ.3 ) THEN
C- Allocate memory to a new variable.
IF ( LVAR.GE.LCLOC ) STOP 'FNCOD--OUT OF FLOATING MEMORY.'
LVAR=LVAR+1
Icode=6000+LVAR
ELSE IF ( IFUNC.EQ.4 ) THEN
IENTRY=ILOC
IPC=ILOC
ELSE IF ( IFUNC.EQ.-1 ) THEN
C- Program at specified location
Icode=IPROG(ILOC)
ELSE IF ( IFUNC.EQ.-2 ) THEN
C- Read constant
VALUE=FMEM(ILOC)
ELSE IF ( IFUNC.EQ.-3 ) THEN
C- Prepare to run program
IF ( ISPT.GT.0 ) THEN
VALUE=STACK(ISPT)
ELSE
VALUE=NO
END IF
IPC=IENTRY
IRPT=0
ISPT=0
ELSE IF ( IFUNC.EQ.-4 ) THEN
C- Print stack
IF ( ICOMP.EQ.0 ) THEN
WRITE(*,*) (STACK(K),K=1,ISPT)
END IF
ELSE IF ( IFUNC.EQ.-5 ) THEN
C- Read code at current PC
ILOC=IPC
Icode=IPROG(IPC)
ELSE IF ( IFUNC.EQ.-6 ) THEN
ILOC=IPCNT
ELSE IF ( IFUNC.EQ.-7 ) THEN
C- Read last valid program location
ILOC=lpc
END IF
RETURN
C---
ENTRY FNPMAT(LOC, IPNUM, ier)
FNPMAT = 0.
DO I=1,IPCNT
IF ( LOC.EQ.IPLOC(I) ) THEN
IPNUM=I
ier=0
RETURN
END IF
END DO
IPNUM=0
ier=1
RETURN
END
C*********
SUBROUTINE CODADD(CWORD, LWORD, IVAL, ier)
CHARACTER CWORD*(*)
INTEGER LWORD, IVAL, ier
C Entry CODCTI
CHARACTER CWORD1*(*)
INTEGER LWORD1, IVAL1, ier1
C Entry CODITC
CHARACTER CWORD2*(*)
INTEGER Icode2, LWORD2, ier2
C Entry CODWOR
CHARACTER CWORD3*(*)
INTEGER IWNUM, LWORD3, ier3
C---
C Add a word to the dictionary. The structure of a dictionary
C entry is:
C length : contains
C ------ --------
C 1 LWORD, length of the current word in bytes
C 1 LPAR, length of the parameter field in bytes
C LWORD CWORD(:LWORD) the word
C IPAR the parameter field (currently is only the I*2 code).
C---
C 1989-Feb-13 - Latest mod [AFT]
C---
INTEGER MXDIC
PARAMETER (MXDIC=1000)
CHARACTER CDIC*(MXDIC)
SAVE CDIC
CHARACTER C2tmp*2
INTEGER icnt, IPAR, IPOS, Itmp, ltok, LPAR
INTEGER LDIC
SAVE LDIC
DATA LDIC/0/
C---
IF ( LWORD.LT.0 ) THEN
LDIC=0
ELSE IF ( LDIC+LWORD+4.GT.MXDIC ) THEN
ier=1
ELSE
ier=0
CDIC(LDIC+1:LDIC+1)=CHAR(LWORD)
CDIC(LDIC+2:LDIC+2)=CHAR(2)
CDIC(LDIC+3:LDIC+2+LWORD)=CWORD(:LWORD)
CALL I4TOC2(IVAL, C2tmp)
CDIC(LDIC+3+LWORD:LDIC+4+LWORD)=C2tmp
LDIC=LDIC+4+LWORD
END IF
RETURN
C---
ENTRY CODCTI(CWORD1, LWORD1, IVAL1, ier1)
C---
C Find the character CWORD in the dictionary.
C---
IPOS=0
200 IF ( IPOS.LT.LDIC ) THEN
ltok=ICHAR(CDIC(IPOS+1:IPOS+1))
LPAR=ICHAR(CDIC(IPOS+2:IPOS+2))
Itmp=IPOS+2+ltok+LPAR
IF ( LWORD1.EQ.ltok ) THEN
IF ( CWORD1(:LWORD1).EQ.CDIC(IPOS+3:IPOS+2+ltok) ) THEN
ier1=0
CALL C2TOI4(CDIC(Itmp-1:Itmp), IVAL1)
RETURN
END IF
END IF
IPOS=Itmp
GOTO 200
END IF
ier1=1
RETURN
C---
ENTRY CODITC(Icode2, CWORD2, LWORD2, ier2)
C---
C Find the code, Icode2, in the dictionary.
C---
IPOS=0
300 IF ( IPOS.LT.LDIC ) THEN
ltok=ICHAR(CDIC(IPOS+1:IPOS+1))
LPAR=ICHAR(CDIC(IPOS+2:IPOS+2))
Itmp=IPOS+2+ltok+LPAR
C2tmp=CDIC(Itmp-1:Itmp)
CALL C2TOI4(C2tmp, IPAR)
IF ( IPAR.EQ.Icode2 ) THEN
LWORD2=ltok
CWORD2(:LWORD2)=CDIC(IPOS+3:IPOS+2+LWORD2)
ier2=0
RETURN
END IF
IPOS=Itmp
GOTO 300
END IF
LWORD2=0
CWORD2(1:2)=' '
ier2=1
RETURN
C---
ENTRY CODWOR(IWNUM, CWORD3, LWORD3, ier3)
C---
C Return the token corresponding to word number IWNUM.
C---
icnt=0
IPOS=0
400 IF ( IPOS.LT.LDIC ) THEN
icnt=icnt+1
ltok=ICHAR(CDIC(IPOS+1:IPOS+1))
LPAR=ICHAR(CDIC(IPOS+2:IPOS+2))
IF ( icnt.EQ.IWNUM ) THEN
LWORD3=ltok
CWORD3(:LWORD3)=CDIC(IPOS+3:IPOS+2+LWORD3)
ier3=0
RETURN
END IF
IPOS=IPOS+2+ltok+LPAR
GOTO 400
END IF
ier3=1
RETURN
END
C*********
SUBROUTINE CODDER(X, PAR, PLIM, DERIV, NT, NTERM)
REAL X(2), PAR(*), PLIM(3,*), DERIV(*)
INTEGER NT, NTERM
C---
C This routine takes the derivative of the FNCOD function with
C respect to the various parameters. This is done numerically.
C---
C 1988-Nov-30 - [AFT]
C---
REAL FNCOD
REAL DX, FNY0, Ptmp, tmp
INTEGER I, ier
C---
FNY0 = FNCOD(0,0,X,PAR(NT),NTERM,ier)
DO I=NT,NT+NTERM-1
IF ( PLIM(1,I).GE.0. ) THEN
Ptmp = PAR(I)
tmp = ABS(Ptmp)
IF ( tmp.GT.0.01 .AND. tmp.LT.100. ) THEN
C- For scaled parameters, use a fixed step size. This is more
C- numerically stable.
DX = .001
ELSE IF ( tmp.LT.1.E-15 ) THEN
C- Near zero, avoid divide by zero problems.
DX = .001
ELSE
DX = .001*tmp
END IF
PAR(I) = PAR(I)+DX
DERIV(I) = (FNCOD(0,0,X,PAR(NT),NTERM,ier)-FNY0)/DX
PAR(I) = Ptmp
END IF
END DO
RETURN
END
C*********
SUBROUTINE C2TOI4(cbuf, I4BUF)
CHARACTER cbuf*2
INTEGER I4BUF
C---
C Convert a CHARACTER*2 into an INTEGER.
C---
CHARACTER c2tmp*2
INTEGER*2 i2tmp
EQUIVALENCE (c2tmp,i2tmp)
C---
c2tmp = cbuf
I4BUF = i2tmp
RETURN
END
C*********
SUBROUTINE I4TOC2(I4BUF, cbuf)
INTEGER I4BUF
CHARACTER cbuf*2
C---
C Convert an INTEGER*4 into a CHARACTER*2
C---
CHARACTER c2tmp*2
INTEGER*2 i2tmp
EQUIVALENCE (c2tmp,i2tmp)
C---
i2tmp = I4BUF
cbuf = c2tmp
RETURN
END
fv5.5/tcltk/plt/cram.f 0000644 0002207 0000036 00000027350 13224715127 013541 0 ustar birby lhea C--- CRAM.FOR contains entry points for:
C CRAMDF
C CRAMFF
C CRAMF
C CRAMI
C CRAMI8
C CRAMIF
C CRAM
C*********
SUBROUTINE CRAMDF(Dnum, Nspace, Ndig, Cbuf, Lbuf)
DOUBLE PRECISION Dnum
INTEGER Nspace, Ndig, Lbuf
CHARACTER Cbuf*(*)
C---
C Do a formatted conversion of Dnum into ASCII characters. If NDIG>0
C then the NDIG right of decimal point will be diplayed using an F format.
C If this would cause more than MXDIG digits to be displayed, then E
C format with maximum accuracy will be used instead. If NDIG<0 then
C only ABS(NDIG) of the number will be displayed, in F format it possible,
C G format otherwise. Using NDIG=0 is equivalent to calling CRAMF.
C In all cases a minimum of NSPACE characters are used in CBUF and leading
C blanks are used to fill in the extra space. If the number cannot
C be expressed in NSPACE characters, then the additional space is
C allocated to the buffer to write the number. This messes up a nice
C neat column format, I like this better than not seeing the number
C at all.
C---
C Dnum I Number to convert
C NSPACE I Number of spaces to use in CBUF
C NDIG I Number of digits to output. NDIG=0 outputs all digits.
C CBUF I/O Character buffer
C LBUF I/O Number of valid characters in CBUF
C---
C 2003-Jan-24 - Extracted from CRAMFF [AFT]
C---
DOUBLE PRECISION NO
PARAMETER (NO=-1.2D-34)
C MXDIG is the maximum number of digits that can be represented in a
C single precision floating point number.
INTEGER MXDIG
PARAMETER (MXDIG=14)
INTEGER LENACT
C
CHARACTER cdum*32, cform*32
INTEGER i, iexp, itmp, kp, ldum, nf, ng
C---
IF ( Dnum.EQ.NO ) THEN
C No data magic number
cdum = 'NO'
ldum = 2
ELSE IF ( Dnum.NE.Dnum ) THEN
C Must be a IEEE NaN, output as No data
cdum = 'NO'
ldum = 2
ELSE IF ( Dnum.EQ.0. ) THEN
C Zero, special case
cdum = ' 0'
ldum = 2
ELSE
IF ( Ndig.EQ.0 ) THEN
C Write all digits of number.
WRITE (cdum,*) Dnum
C 171 FORMAT(1PG14.7)
CALL CRAM(cdum,ldum)
ELSE
C IEXP is the exponent when number is expressed in scientific notation.
iexp = INT(500.+LOG10(ABS(Dnum))) - 500
C
IF ( Ndig.GT.0 ) THEN
C Display NDIG right of decimal point
nf = MIN(Ndig,MXDIG)
ng = MXDIG - 1
ELSE
C Display ABS(NDIG) total
ng = MIN(ABS(Ndig),MXDIG) - 1
nf = ng - iexp
END IF
C---
C If only displaying 0 to MXDIG digits right of decimal point AND if
C fewer than MXDIG total digits are to be displayed,
IF ( 0.LE.nf .AND. nf.LE.Nspace .AND. (nf+iexp+1).LE.MXDIG )
& THEN
C then use F format,
IF ( nf.LE.9 ) THEN
WRITE (cform,121) nf
121 FORMAT ('(F14.',I1,')')
ELSE
WRITE (cform,131) nf
131 FORMAT ('(F14.',I2,')')
END IF
ELSE
C else use G Format. Note, there is a bug in that if the number is displayed
C in an F FORMAT, then the scale factor is not applied, and one too few
C digits is displayed.
IF ( ng.LE.9 ) THEN
WRITE (cform,141) ng
141 FORMAT ('(1PE20.',I1,')')
ELSE
WRITE (cform,151) ng
151 FORMAT ('(1PE20.',I2,')')
END IF
C---
END IF
WRITE (cdum,cform) Dnum
ldum = LENACT(cdum)
C---
C Now strip leading blanks (if any).
kp = 0
CALL ALFSKS(cdum,ldum,kp)
IF ( kp.GT.0 ) THEN
DO 100 i = 1, ldum - kp
cdum(i:i) = cdum(i+kp:i+kp)
100 CONTINUE
ldum = ldum - kp
END IF
END IF
END IF
C---
C Copy to output buffer, right justified.
IF ( ldum.LE.Nspace ) THEN
itmp = Nspace - ldum
Cbuf(Lbuf+1:Lbuf+itmp) = ' '
Cbuf(Lbuf+itmp+1:Lbuf+Nspace) = cdum(:ldum)
Lbuf = Lbuf + Nspace
ELSE
Cbuf(Lbuf+1:Lbuf+ldum) = cdum(:ldum)
Lbuf = Lbuf + ldum
END IF
RETURN
END
C*********
SUBROUTINE CRAMFF(Fnum,Nspace,Ndig,Cbuf,Lbuf)
REAL Fnum
INTEGER Nspace, Ndig, Lbuf
CHARACTER Cbuf*(*)
C---
C Do a formatted conversion of FNUM into ASCII characters. If NDIG>0
C then the NDIG right of decimal point will be diplayed using an F format.
C If this would cause more than MXDIG digits to be displayed, then E
C format with maximum accuracy will be used instead. If NDIG<0 then
C only ABS(NDIG) of the number will be displayed, in F format it possible,
C G format otherwise. Using NDIG=0 is equivalent to calling CRAMF.
C In all cases a minimum of NSPACE characters are used in CBUF and leading
C blanks are used to fill in the extra space. If the number cannot
C be expressed in NSPACE characters, then the additional space is
C allocated to the buffer to write the number. This messes up a nice
C neat column format, I like this better than not seeing the number
C at all.
C---
C FNUM I Number to convert
C NSPACE I Number of spaces to use in CBUF
C NDIG I Number of digits to output. NDIG=0 outputs all digits.
C CBUF I/O Character buffer
C LBUF I/O Number of valid characters in CBUF
C---
C 1992-Sep-01 - rewrite [AFT]
C 1994-May-12 - Add test for NaN [AFT]
C---
REAL NO
PARAMETER (NO=-1.2E-34)
C MXDIG is the maximum number of digits that can be represented in a
C single precision floating point number.
INTEGER MXDIG
PARAMETER (MXDIG=7)
INTEGER LENACT
C
CHARACTER cdum*32, cform*32
INTEGER i, iexp, itmp, kp, ldum, nf, ng
C---
IF ( Fnum.EQ.NO ) THEN
C No data magic number
cdum = 'NO'
ldum = 2
ELSE IF ( Fnum.NE.Fnum ) THEN
C Must be a IEEE NaN, output as No data
cdum = 'NO'
ldum = 2
ELSE IF ( Fnum.EQ.0. ) THEN
C Zero, special case
cdum = ' 0'
ldum = 2
ELSE
IF ( Ndig.EQ.0 ) THEN
C Write all digits of number.
WRITE (cdum,*) Fnum
C 171 FORMAT(1PG14.7)
CALL CRAM(cdum,ldum)
ELSE
C IEXP is the exponent when number is expressed in scientific notation.
iexp = INT(500.+LOG10(ABS(Fnum))) - 500
C
IF ( Ndig.GT.0 ) THEN
C Display NDIG right of decimal point
nf = MIN(Ndig,MXDIG)
ng = MXDIG - 1
ELSE
C Display ABS(NDIG) total
ng = MIN(ABS(Ndig),MXDIG) - 1
nf = ng - iexp
END IF
C---
C If only displaying 0 to MXDIG digits right of decimal point AND if
C fewer than MXDIG total digits are to be displayed,
IF ( 0.LE.nf .AND. nf.LE.MXDIG .AND. (nf+iexp+1).LE.MXDIG )
& THEN
C then use F format,
WRITE (cform,121) nf
121 FORMAT ('(F14.',I1,')')
ELSE
C else use G Format. Note, there is a bug in that if the number is displayed
C in an F FORMAT, then the scale factor is not applied, and one too few
C digits is displayed.
WRITE (cform,141) ng
141 FORMAT ('(1PE14.',I1,')')
C---
END IF
WRITE (cdum,cform) Fnum
ldum = LENACT(cdum)
C---
C Now strip leading blanks (if any).
kp = 0
CALL ALFSKS(cdum,ldum,kp)
IF ( kp.GT.0 ) THEN
DO 100 i = 1, ldum - kp
cdum(i:i) = cdum(i+kp:i+kp)
100 CONTINUE
ldum = ldum - kp
END IF
END IF
END IF
C---
C Copy to output buffer, right justified.
IF ( ldum.LE.Nspace ) THEN
itmp = Nspace - ldum
Cbuf(Lbuf+1:Lbuf+itmp) = ' '
Cbuf(Lbuf+itmp+1:Lbuf+Nspace) = cdum(:ldum)
Lbuf = Lbuf + Nspace
ELSE
Cbuf(Lbuf+1:Lbuf+ldum) = cdum(:ldum)
Lbuf = Lbuf + ldum
END IF
RETURN
END
C*********
SUBROUTINE CRAMF(Fnum,Cbuf,Lbuf)
REAL Fnum
CHARACTER Cbuf*(*)
INTEGER Lbuf
C---
C Convert floating point number into ASCII characters and
C append to CBUF.
C---
C FNUM I Number to convert
C CBUF I/O Character buffer
C LBUF I/O Number of valid characters in CBUF
C---
C AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
CHARACTER cdum*32
INTEGER ldum
C---
IF ( Fnum.NE.NO ) THEN
WRITE (cdum,*) Fnum
C 121 FORMAT(1PG14.7)
CALL CRAM(cdum,ldum)
ELSE
cdum = 'NO'
ldum = 2
END IF
Cbuf(Lbuf+1:Lbuf+ldum) = cdum
Lbuf = Lbuf + ldum
RETURN
END
C*********
SUBROUTINE CRAMI(Inum,Cbuf,Lbuf)
INTEGER Inum, Lbuf
CHARACTER Cbuf*(*)
C---
C Convert integer number into ASCII characters and
C append to CBUF.
C---
C INUM I Number to convert
C CBUF I/O Character buffer
C LBUF I/O Number of valid characters in CBUF
C---
C AFT
C---
CHARACTER cdum*32
INTEGER ldum
C---
WRITE (cdum,101) Inum
101 FORMAT (I32)
CALL CRAM(cdum,ldum)
Cbuf(Lbuf+1:Lbuf+ldum) = cdum
Lbuf = Lbuf + ldum
RETURN
END
C*********
SUBROUTINE CRAMI8(I8num,Cbuf,Lbuf)
INTEGER*8 I8num
INTEGER Lbuf
CHARACTER Cbuf*(*)
C---
C Convert integer number into ASCII characters and
C append to CBUF.
C---
C I8NUM I Number to convert
C CBUF I/O Character buffer
C LBUF I/O Number of valid characters in CBUF
C---
C 2008-May-15 - Extract from CRAMI - AFT
C---
CHARACTER cdum*32
INTEGER ldum
C---
WRITE (cdum,101) I8num
101 FORMAT (I32)
CALL CRAM(cdum,ldum)
Cbuf(Lbuf+1:Lbuf+ldum) = cdum
Lbuf = Lbuf + ldum
RETURN
END
C*********
SUBROUTINE CRAMIF(Inum,Nspace,Cbuf,Lbuf)
INTEGER Inum, Nspace, Lbuf
CHARACTER Cbuf*(*)
C---
C Convert integer number into ASCII characters and append to CBUF.
C---
C INUM I Number to convert
C NSPACE I Number of characters to pack number into
C CBUF I/O Character buffer
C LBUF I/O Number of valid characters in CBUF
C---
C AFT
C---
CHARACTER cdum*32
INTEGER ldum, il, nc
C---
WRITE (cdum,101) Inum
101 FORMAT (I32)
CALL CRAM(cdum,ldum)
nc = MAX(Nspace,ldum)
il = 1 + nc - ldum
Cbuf(Lbuf+il:Lbuf+nc) = cdum
Lbuf = Lbuf + nc
RETURN
END
C*********
SUBROUTINE CRAM(Cdum,Ldum)
CHARACTER Cdum*(*)
INTEGER Ldum
C---
C Remove redundant information.
C---
C CBUF I/O Character buffer
C LBUF O Number of valid characters in CBUF
C---
C AFT
C---
INTEGER LENACT
INTEGER i, id, ie
C---
C- Remove leading blanks.
i = 1
100 IF ( Cdum(i:i).EQ.' ' ) THEN
i = i + 1
GOTO 100
END IF
Cdum = Cdum(i:)
C- Remove 0 in E+0x or E-0x
ie = INDEX(Cdum,'E+0')
IF ( ie.LE.0 ) ie = INDEX(Cdum,'E-0')
IF ( ie.GT.0 ) Cdum(ie+2:) = Cdum(ie+3:) // ' '
C- Remove trailing E+0
Ldum = LENACT(Cdum)
IF ( Ldum.GT.2 ) THEN
IF ( Cdum(Ldum-2:).EQ.'E+0' ) THEN
Cdum(Ldum-2:Ldum) = ' '
Ldum = Ldum - 3
END IF
END IF
C- Remove trailing zeros.
id = INDEX(Cdum,'.')
IF ( id.NE.0 ) THEN
ie = INDEX(Cdum,'E') - 1
IF ( ie.LE.0 ) ie = Ldum
DO 130 i = ie, id + 1, -1
IF ( Cdum(i:i).NE.'0' ) GOTO 190
Cdum(i:) = Cdum(i+1:) // ' '
130 CONTINUE
END IF
C
190 Ldum = LENACT(Cdum)
C- Remove trailing .
IF ( Cdum(Ldum:Ldum).EQ.'.' ) Ldum = Ldum - 1
IF ( Ldum.EQ.0 ) THEN
C- CRAM will transform .000000 into a blank string, which really should
C- be zero.
Ldum = 1
Cdum(1:1) = '0'
ELSE
C- Blank fill.
DO 200 i = Ldum + 1, LEN(Cdum)
Cdum(i:i) = ' '
200 CONTINUE
END IF
RETURN
END
fv5.5/tcltk/plt/curfit.f 0000644 0002207 0000036 00000030063 13224715127 014106 0 ustar birby lhea SUBROUTINE CURFIT(Rdat, Igrp, iy0, Iery, Mxrow, Low, Npts,
& Xmin, Xmax, Ichat, Niter, Istat, Icomp, Idoun, Nterm,
& Fdelmn, Pval, Plim, Chisq)
INTEGER Igrp, iy0, Iery, Mxrow, Low, Npts
INTEGER Ichat, Niter, Icomp(*), Idoun, Nterm, Istat
REAL Rdat(*), Xmin(*), Xmax(*), Pval(*), Plim(3, *)
REAL Fdelmn, Chisq
C---
C Closely parallels CURFIT given in Bevington p.238
C Contains a vector-subset capability, used by setting Plim(1, I)<0.
C---
C Rdat I The data array
C Igrp I Used by pltxc to calculate the X coordinate(s).
C Iy0 I Y(iy0+I) is the y-value of the Ith data point.
C Iery I Errors, <0 statistical, =0 none, >0 explicit errors.
C Mxrow I Used by function WEIGHT (needed for explicit errors)
C Low I The first data point in the fit range (typically=1).
C Npts I The last data point in the fit range.
C Xmin I The smallest X to include in fit.
C Xmax I The largest X to include in fit.
C Ichat I >0 display messages and questions, =0 display messages
C -but no questions, -1 no messages or questions
C -2 total quiet
C Niter I Number of iterations (0 defaults to 10)
C Istat I The statistic to be used: 0=Chi-squared, 1=M-L
C Icomp I Passed to FITLIM, FNFIT and MDERIV.
C Idoun I =1 estimate uncertainties, =0 don't estimate uncertainties.
C Nterm I The number of terms.
C Fdelmn I Stop when delta less than (0 defaults to 0.05 or 0.001 2D)
C Pval I/O The whole reason for calling CURFIT.
C Plim I/O PLIM(1, I)<0 indicates parameter is frozen.
C Chisq O The value of Chi-squared. -N insensitive to parameter N.
C---
C 1998-09-30 - Changed the ML statistic to the current version used
C by xspec (the famous Castor priv comm function). Multiplied
C by Rdat*Weight to convert to rates to counts. Finally
C do not allow the model to fall below 1.0E-6 counts/bin.
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXDIM, MXPAR, MXFREE
PARAMETER (MXDIM=2, MXPAR=120, MXFREE=100)
REAL FNFIT, WEIGHT
C
REAL xt(MXDIM)
REAL chisq1, chil, del, delmin, derj, dif, flamda, fudge
REAL rcon, rlndat, rlnmod, tot, wtmp, rmod
INTEGER idef
SAVE idef
INTEGER i, ians, icnt, ihit, iycol, iyi, iyoff
INTEGER j, ji, k, ndim, nidim, ntry, nvar
C Length of CURFIT common block is 3*MXFREE*(MXFREE+2).
INTEGER Index, Ik, Jk
REAL Beta, B, Deriv, Alpha
DOUBLE PRECISION Aray
COMMON /CURCMN/ Index(MXFREE), Ik(MXFREE), Jk(MXFREE),
& Beta(MXFREE), B(MXFREE), Deriv(MXPAR),
& Alpha(MXFREE, MXFREE), Aray(MXFREE, MXFREE)
DATA idef/ -1/
C---
IF ( Fdelmn.GT.0.0 ) THEN
delmin=Fdelmn
ELSE
delmin = 0.05
CALL PLTXCC(Rdat, 1, Igrp, xt, nidim, iyoff)
IF ( nidim.GT.1 ) delmin=0.001
END IF
ntry = 10
IF ( Niter.NE.0 ) ntry = Niter
flamda = .001
Chisq = 0.
icnt = 0
nvar = 0
DO j = 1, Nterm
IF ( Plim(1,j).GE.0. ) THEN
nvar = nvar + 1
IF ( nvar.GT.MXFREE ) THEN
WRITE(*, 101) MXFREE
101 FORMAT(' CURFIT--Can only vary', I6,
& ' parameters at a time.')
RETURN
END IF
Index(nvar) = j
END IF
END DO
C- Clear BETA and ALPHA.
120 CONTINUE
chil = Chisq
DO j = 1, nvar
Beta(j) = 0.
DO k = 1, j
Alpha(j, k) = 0.
END DO
END DO
C- Evaluate derivatives, CHISQ, ALPHA and BETA at starting point.
chisq1 = 0.
rcon = 1.0
DO 160 i = Low, Npts
CALL PLTXCC(Rdat, i, Igrp, xt, ndim, iyoff)
IF ( xt(1).EQ.NO ) GOTO 160
IF ( xt(1).LT.XMIN(1) .OR. xt(1).GT.XMAX(1) ) GOTO 160
IF ( nidim.GT.1 ) THEN
IF ( xt(2).LT.XMIN(2) .OR. xt(2).GT.XMAX(2) ) GOTO 160
END IF
iyi = iy0 + iyoff
rmod = FNFIT(xt, Icomp, Pval, Nterm)
IF ( rmod.EQ.NO .OR. Rdat(iyi).EQ.NO ) GOTO 160
wtmp = WEIGHT(Rdat(iyi), Mxrow, Iery)
IF ( Istat.EQ.0 ) THEN
dif = Rdat(iyi) - rmod
IF ( ABS(dif).LT.1.E15 ) THEN
chisq1 = chisq1 + wtmp*dif*dif
ELSE
chisq1 = chisq1 + 1.E32
END IF
ELSE
C rcon is the divisor that converted counts to flux. For Iery.LE.0
C rcon=1.0 which is set outside the loop.
IF ( Rdat(iyi).EQ.0.0 ) THEN
IF ( Iery.GT.0 ) rcon = SQRT(wtmp)
rlndat = 0.0
ELSE
IF ( Iery.GT.0 ) rcon = wtmp*Rdat(iyi)
rlndat = LOG(rcon*Rdat(iyi))
END IF
C Assume exact value of the model becomes useless below 1.0E-6 count/bin.
rmod = MAX(rmod, 1.0E-6/rcon)
dif = Rdat(iyi)/rmod
rlnmod = LOG(rcon*rmod)
C chisq1 = chisq1 + 2*((rcon*rmod+
C & GAMMLN(rcon*Rdat(iyi)+1))-rcon*Rdat(iyi)*rlnmod)
chisq1 = chisq1 + 2*rcon*(rmod+
& Rdat(iyi)*(rlndat-rlnmod-1.0))
END IF
IF ( nvar.LE.0 ) GOTO 160
CALL MDERIV(xt, Icomp, Pval, Plim, Nterm, Deriv)
DO j = 1, nvar
ji = Index(j)
IF ( Istat.EQ.0 ) THEN
Beta(j) = Beta(j) + wtmp*dif*Deriv(ji)
derj = wtmp*Deriv(ji)
ELSE
Beta(j) = Beta(j) + rcon*(dif-1.)*Deriv(ji)
derj = rcon*dif*Deriv(ji)/rmod
END IF
DO k = 1, j
Alpha(j, k) = Alpha(j, k) + derj*Deriv(Index(k))
END DO
END DO
160 CONTINUE
IF ( nvar.LE.0 ) GOTO 900
C- Symmetrize ALPHA.
DO j = 1, nvar
IF ( Alpha(j, j).EQ.0. ) GOTO 810
DO k = 1, j
Alpha(k, j) = Alpha(j, k)
END DO
END DO
DO j = 1, Nterm
B(j) = Pval(j)
END DO
C- Modify and invert the curvature matrix.
190 CONTINUE
DO j = 1, nvar
DO k = 1, nvar
Aray(j, k) = Alpha(j, k)/SQRT(Alpha(j, j)*Alpha(k, k))
END DO
Aray(j, j) = 1. + flamda
END DO
CALL MATINV(Aray, MXFREE, nvar, Ik, Jk)
C- Construct the trial parameter set.
DO j = 1, nvar
tot = 0.
DO k = 1, nvar
tot = tot + Beta(k)*Aray(j, k)/SQRT(Alpha(j, j)*Alpha(k, k))
END DO
Pval(Index(j)) = B(Index(j)) + tot
END DO
CALL FITLIM(Icomp, Pval, Plim, Nterm, ihit)
C---
C- Compute new CHISQ.
Chisq = 0.
rcon = 1.0
DO 280 i = Low, Npts
CALL PLTXCC(Rdat, i, igrp, xt, ndim, iyoff)
IF ( xt(1).EQ.NO ) GOTO 280
IF ( xt(1).LT.XMIN(1) .OR. xt(1).GT.XMAX(1) ) GOTO 280
IF ( nidim.GT.1 ) THEN
IF ( xt(2).LT.XMIN(2) .OR. xt(2).GT.XMAX(2) ) GOTO 280
END IF
iyi = iy0 + iyoff
rmod = FNFIT(xt, Icomp, Pval, Nterm)
IF ( rmod.EQ.NO .OR. Rdat(iyi).EQ.NO ) GOTO 280
wtmp = WEIGHT(Rdat(iyi), Mxrow, Iery)
IF ( Istat.EQ.0 ) THEN
dif = MIN(ABS(Rdat(iyi)-rmod), 1.E15)
Chisq = Chisq + wtmp*dif*dif
ELSE
IF ( Rdat(iyi).EQ.0.0 ) THEN
IF ( Iery.GT.0 ) rcon = SQRT(wtmp)
rlndat = 0.0
ELSE
IF ( Iery.GT.0 ) rcon = wtmp*Rdat(iyi)
rlndat = LOG(rcon*Rdat(iyi))
END IF
rmod = MAX(rmod, 1.0E-6/rcon)
rlnmod = LOG(rcon*rmod)
Chisq = Chisq + 2*rcon*(rmod+
& Rdat(iyi)*(rlndat-rlnmod-1.0))
END IF
280 CONTINUE
C- If CHI SQUARED increased, increase FLAMDA and try again.
IF ( Chisq.GT.chisq1 ) THEN
IF ( flamda.LT.0.9E10 ) THEN
flamda = 10.*flamda
GOTO 190
END IF
C- Trick to force termination condition.
chil = Chisq
END IF
C---
IF ( Ichat.GE.0 ) WRITE (*, 301) NINT(LOG10(flamda)), Chisq
301 FORMAT (' (', I3, ') W-VAR=', 1PG10.4)
C-
IF ( flamda.GT.1.E-20 ) flamda = flamda/10.
icnt = icnt + 1
del = ABS(chil-Chisq)
C- Unweighted, consider relative change.
IF ( Iery.EQ.0 .AND. Chisq.GT.0. ) del = del/Chisq
IF ( Chisq.LE.0. .OR. del.LE.delmin ) GOTO 330
C- Keep trying until ICNT.GE.NTRY.
IF ( icnt.LT.ntry ) GOTO 120
icnt = 0
IF ( Ichat.GT.0 ) THEN
CALL YORN('Continue fitting', idef, ians)
IF ( ians.GT.0 ) GOTO 120
END IF
WRITE (*, 321)
321 FORMAT (' CURFIT--Minimum not found.')
C---
C- Exit. Evaluate uncertainties by inverting matrix with FLAMDA=0.
330 CONTINUE
IF ( Idoun.NE.0 ) THEN
DO j = 1, nvar
DO k = 1, nvar
Aray(j, k) = Alpha(j, k)
END DO
END DO
CALL MATINV(Aray, MXFREE, nvar, Ik, Jk)
fudge = 1.0
IF ( Iery.EQ.0 .AND. Istat.EQ.0) THEN
C For unweighted chisq, scale the uncertainty.
IF ( Chisq.GT.0. ) fudge=(Pval(nterm+2)-nvar)/Chisq
END IF
DO j = 1, nvar
ji = Index(j)
Plim(1, ji) = SQRT(ABS(Aray(j, j))/fudge)
END DO
END IF
RETURN
C---
810 CONTINUE
IF ( ichat.GT.-2 ) THEN
WRITE(*, 811) Index(j)
811 FORMAT(' CURFIT--Model insensitive to parameter', I6)
END IF
Chisq = -Index(j)
RETURN
C---
900 CONTINUE
Chisq = chisq1
IF ( Ichat.GE.0 ) WRITE (*, 301) NINT(LOG10(flamda)), Chisq
RETURN
END
C*********
SUBROUTINE MATINV(Aray, Mxfree, Norder, Ik, Jk)
INTEGER Mxfree, Norder, Ik(Mxfree), Jk(Mxfree)
DOUBLE PRECISION Aray(Mxfree, Mxfree)
C---
C This subroutine replaces a real, square, symmetric matrix with
C its inverse see P.R.Bevington, "Data Reduction and Error Analysis
C For the Physical Sciences" McGraw-Hill, N.Y., 1969 p.302.
C---
C Aray I/O
C Mxfree I
C Norder I
C Ik O
C Jk O
C---
DOUBLE PRECISION amax, save
INTEGER i, j, k, l
C---
DO k = 1, Norder
C- Find largest element in matrix.
amax = 0.
DO 150 i = k, Norder
DO j = k, Norder
C IF ( DABS(amax)-DABS(Aray(i, j)) ) 130, 130, 150
IF ( DABS(amax)-DABS(Aray(i, j)).GT.0.0 ) GOTO 150
130 amax = Aray(i, j)
Ik(k) = i
Jk(k) = j
END DO
150 CONTINUE
C- Interchange rows and columns to put AMAX in ARAY(K, K)
C IF ( amax ) 180, 420, 180
IF ( amax.EQ.0.0 ) GOTO 420
180 i = Ik(k)
C IF ( i-k ) 210, 210, 190
IF ( i-k.LE.0 ) GOTO 210
190 CONTINUE
DO j = 1, Norder
save = Aray(k, j)
Aray(k, j) = Aray(i, j)
Aray(i, j) = -save
END DO
210 j = Jk(k)
C IF ( j-k ) 240, 240, 220
IF ( j-k.LE.0 ) GOTO 240
220 CONTINUE
DO i = 1, Norder
save = Aray(i, k)
Aray(i, k) = Aray(i, j)
Aray(i, j) = -save
END DO
C- Accumulate the elements of the inverse martix.
240 CONTINUE
DO i = 1, Norder
IF ( i.NE.k ) Aray(i, k) = -Aray(i, k)/amax
END DO
DO i = 1, Norder
DO j = 1, Norder
IF ( i.NE.k .AND. j.NE.k ) Aray(i, j) = Aray(i, j)
& + Aray(i, k)*Aray(k, j)
END DO
END DO
DO j = 1, Norder
IF ( j.NE.k ) Aray(k, j) = Aray(k, j)/amax
END DO
Aray(k, k) = 1./amax
END DO
C---
C- Restore ordering of the matrix.
DO 410 l = 1, Norder
k = Norder - l + 1
j = Ik(k)
C IF ( j-k ) 380, 380, 360
IF ( j-k.LE.0 ) GOTO 380
360 CONTINUE
DO i = 1, Norder
save = Aray(i, k)
Aray(i, k) = -Aray(i, j)
Aray(i, j) = save
END DO
380 CONTINUE
i = Jk(k)
C IF ( i-k ) 410, 410, 390
IF ( i-k.LE.0 ) GOTO 410
390 CONTINUE
DO j = 1, Norder
save = Aray(k, j)
Aray(k, j) = -Aray(i, j)
Aray(i, j) = save
END DO
410 CONTINUE
420 RETURN
END
fv5.5/tcltk/plt/dscale.f 0000644 0002207 0000036 00000025507 13224715127 014054 0 ustar birby lhea SUBROUTINE DSCALE(Y, Iery, Mxrow, Mxwin, Mx2d, Ngroup, Mxpar,
& Igap, Rgap, Idoall, Iskip, Newmod, Iactw, Logx, Logy, Imaster,
& Igrpos, Ipwin, Icont, Image, Ipmod, Icomp, Pval, Nterm,
& Imnmx, Xymnmx, Ermnmx, Xyscal)
INTEGER Mxrow, Mxwin, Mx2d, Ngroup, Mxpar
INTEGER Igap, Idoall, Iskip, Newmod, Imnmx
INTEGER Iery(*), Ipwin(*), Iactw(*), Logx(*), Logy(*)
INTEGER Igrpos(3, *), Icont(*), Image(*)
INTEGER Ipmod(*), Icomp(2*Mxpar, *), Nterm(*), Imaster(2,*)
REAL Rgap
REAL Y(*), Pval(Mxpar, *)
REAL Xymnmx(4, *), Ermnmx(4, *), Xyscal(4, *)
C---
C Find the min and max data values, and set the default PLT scales.
C We must set the scale for each window. The default is plot group N
C is plotted in window N.
C---
C Y I
C Iery I
C Mxrow I
C Mxwin I Maximum number of windows
C Mx2d I Maximum number of 2D plots
C Ngroup I
C Mxpar I
C Igap I =0 ignore errors, <>0 include error bar in min/max.
C Rgap I
C Idoall I
C Iskip I
C Newmod I
C Iactw I per window
C Logx I Per window
C Logy I Per window
C Imaster I per window
C Igrpos I Per group
C Ipwin I Per group
C Icont I Per group
C Image I per group
C Ipmod I per group
C Pval I per model
C Nterm I per model
C Imnmx I/O
C Xymnmx I/O The data min/max values by group, xmin, ymin, xmax, ymax
C Ermnmx I/O The min/max values with errors, xmin, xmax, ymin, ymax
C Xyscal I/O The window min/max values, xmin, xmax, ymin, ymax
C---
C 1990-Feb-26 - Extracted from PLT [AFT]
C---
REAL NO
PARAMETER (NO=-1.2E-34)
REAL RMAX
PARAMETER (RMAX=1.E35)
INTEGER MXDIM
PARAMETER (MXDIM=2)
REAL FNFIT
C
REAL xt(MXDIM)
REAL tmplo, tmphi, tmp1, tmp2, xcen, xm, xp, yerr, yt
INTEGER i, i2drow, igroup, itmp, iwnum, iy0, iyi, iyoff
INTEGER lery, ndim
C---
C If new data or SKIP has changed, then the plot groups may have
C changed. For this case scan all the groups and reset the Data min
C and max values
IF ( Iskip.NE.Imnmx .OR. Newmod.NE.0 ) THEN
DO 130 igroup = 1, Ngroup
IF ( igrpos(1,igroup).LT.0 ) GOTO 130
IF ( Iskip.EQ.Imnmx .AND. Newmod.NE.ABS(ipmod(igroup)) )
& GOTO 130
Xymnmx(1,igroup) = RMAX
Xymnmx(3,igroup) = -RMAX
Xymnmx(2,igroup) = RMAX
Xymnmx(4,igroup) = -RMAX
C
Ermnmx(1, igroup) = RMAX
Ermnmx(2, igroup) = -RMAX
Ermnmx(3, igroup) = RMAX
Ermnmx(4, igroup) = -RMAX
yerr = 0.0
C
iy0 = Igrpos(1, igroup)
lery = Iery(Igrpos(3, igroup))
IF ( lery.GT.0 ) THEN
i2drow = Mxrow*(lery+1)
ELSE
i2drow = Mxrow
END IF
DO 120 i = 1, Igrpos(2, igroup)
CALL PLTXCC(Y, i, igroup, xt, ndim, iyoff)
IF ( xt(1).EQ.NO ) GOTO 120
xcen = xt(1)
iyi = iy0 + iyoff
yt = Y(iyi)
IF ( ipmod(igroup).LT.0 .AND. yt.NE.NO ) THEN
C ipmod.LT.0 means plot residuals
itmp = ABS(ipmod(igroup))
yt = yt - FNFIT(xcen,ICOMP(1,itmp),
& PVAL(1,itmp),nterm(itmp))
END IF
Xymnmx(1,igroup) = MIN(Xymnmx(1,igroup), xcen)
Xymnmx(3,igroup) = MAX(Xymnmx(3,igroup), xcen)
CALL PLTXCE(Y, i, igroup, 1, xm, xp)
Ermnmx(1, igroup) = MIN(Ermnmx(1, igroup), xcen+xm)
Ermnmx(2, igroup) = MAX(Ermnmx(2, igroup), xcen+xp)
IF ( yt.NE.NO ) THEN
C Min/Max of data
Xymnmx(2,igroup) = MIN(Xymnmx(2,igroup), yt)
Xymnmx(4,igroup) = MAX(Xymnmx(4,igroup), yt)
C Now calculate error
IF ( lery.NE.0 ) THEN
IF ( lery.GT.0 ) THEN
yerr = Y(iyi+Mxrow)
ELSE
IF ( Y(iyi).GT.0.0 ) THEN
yerr = SQRT(Y(iyi))
ELSE
yerr = 1.0
END IF
END IF
END IF
C Min/Max of data with error
Ermnmx(3, igroup) = MIN(Ermnmx(3, igroup), yt-yerr)
Ermnmx(4, igroup) = MAX(Ermnmx(4, igroup), yt+yerr)
END IF
120 CONTINUE
130 CONTINUE
Imnmx = Iskip
Newmod = 0
END IF
C---
C Now set default min and max values in each window.
DO 290 iwnum = 1, Mxwin
IF ( Iactw(iwnum).EQ.0 ) GOTO 290
IF ( Xyscal(1, iwnum).EQ.NO .OR. Xyscal(3, iwnum).EQ.NO ) THEN
C Find min/max X values for all groups plotted in the current window.
tmp1 = RMAX
tmp2 = -RMAX
DO igroup = 1, Ngroup
IF ( igrpos(1,igroup).GE.0 ) THEN
IF ( Idoall.NE.0 ) THEN
IF ( Ipwin(igroup).GT.0 ) THEN
IF ( Igap.EQ.0 ) THEN
tmp1 = MIN(tmp1, Xymnmx(1,igroup))
tmp2 = MAX(tmp2, Xymnmx(3,igroup))
ELSE
tmp1 = MIN(tmp1, Ermnmx(1, igroup))
tmp2 = MAX(tmp2, Ermnmx(2, igroup))
END IF
END IF
ELSE
IF ( Ipwin(igroup).EQ.iwnum ) THEN
IF ( Igap.EQ.0 ) THEN
tmp1 = MIN(tmp1, Xymnmx(1,igroup))
tmp2 = MAX(tmp2, Xymnmx(3,igroup))
ELSE
tmp1 = MIN(tmp1, Ermnmx(1, igroup))
tmp2 = MAX(tmp2, Ermnmx(2, igroup))
END IF
END IF
END IF
END IF
END DO
IF ( tmp1.NE.RMAX ) THEN
CALL PLTGAP(tmp1, tmp2, Rgap, Logx(iwnum), tmplo, tmphi)
ELSE
CALL PLTGAP(Xymnmx(1,iwnum), Xymnmx(3,iwnum), Rgap,
& Logx(iwnum), tmplo, tmphi)
END IF
IF ( Xyscal(1, iwnum).EQ.NO ) Xyscal(1, iwnum) = tmplo
IF ( Xyscal(3, iwnum).EQ.NO ) Xyscal(3, iwnum) = tmphi
END IF
IF ( Xyscal(2, iwnum).EQ.NO .OR. Xyscal(4, iwnum).EQ.NO ) THEN
C Now find min/max of all y coordinate values. Since contours and
C images are handled differently do them first. If no contour/image
C then set scale the old fashion way.
tmp1 = RMAX
tmp2 = -RMAX
xm = 0.0
xp = 0.0
DO igroup = 1, mx2d
IF ( Ipwin(igroup).EQ.iwnum ) THEN
IF ( Icont(igroup).GT.0 .OR.
& Image(igroup).GT.0 ) THEN
C If a contour/image appears in the current window, then the default
C ymax is set by the corners of the 2D array being plotted
CALL PLTXCC(Y, 1, igroup, xt, ndim, iyoff)
IF ( ndim.NE.2 ) GOTO 180
IF ( igap.NE.0 ) THEN
CALL PLTXCE(Y, 1, igroup, 2, xm, xp)
END IF
tmp1 = MIN(tmp1, xt(2)+xm)
tmp2 = MAX(tmp2, xt(2)+xp)
CALL PLTXCC(Y,igrpos(2,igroup),igroup,
& xt,ndim,iyoff)
IF ( igap.NE.0 ) THEN
CALL PLTXCE(Y,igrpos(2,igroup),igroup,2,xm,xp)
END IF
tmp1 = MIN(tmp1, xt(2)+xm)
tmp2 = MAX(tmp2, xt(2)+xp)
END IF
END IF
END DO
IF ( tmp1.NE.RMAX ) GOTO 190
C
C No contour/images in the current window, use the data min/max of
C the plot groups that appear in the window.
180 CONTINUE
tmp1 = RMAX
tmp2 = -RMAX
DO igroup = 1, Ngroup
IF ( Ipwin(igroup).EQ.iwnum ) THEN
IF ( Igap.EQ.0 ) THEN
tmp1 = MIN(tmp1, Xymnmx(2,igroup))
tmp2 = MAX(tmp2, Xymnmx(4,igroup))
ELSE
tmp1 = MIN(tmp1, Ermnmx(3, igroup))
tmp2 = MAX(tmp2, Ermnmx(4, igroup))
END IF
END IF
END DO
190 CONTINUE
IF ( tmp1.NE.RMAX ) THEN
CALL PLTGAP(tmp1, tmp2, Rgap, Logy(iwnum), tmplo, tmphi)
IF ( Xyscal(2, iwnum).EQ.NO ) Xyscal(2, iwnum) = tmplo
IF ( Xyscal(4, iwnum).EQ.NO ) Xyscal(4, iwnum) = tmphi
END IF
END IF
C---
C Check for negative scales when using a LOG plot.
IF ( Logy(iwnum).NE.0 .AND. Xyscal(2, iwnum).LT.0. ) THEN
tmp1 = RMAX
tmp2 = -RMAX
DO igroup = 1, Ngroup
IF ( Ipwin(igroup).EQ.iwnum ) THEN
iy0 = Igrpos(1, igroup)
lery = Iery(Igrpos(3, igroup))
IF ( lery.GT.0 ) THEN
i2drow = Mxrow*(lery+1)
ELSE
i2drow = Mxrow
END IF
DO i = 1, Igrpos(2, igroup)
CALL PLTXCC(Y, i, igroup, xt, ndim, iyoff)
iyi = iy0 + iyoff
IF ( xt(1).NE.NO .AND. Y(iyi).GT.0. ) THEN
tmp1 = MIN(tmp1, Y(iyi))
tmp2 = MAX(tmp2, Y(iyi))
END IF
END DO
END IF
END DO
CALL PLTGAP(tmp1,tmp2,Rgap,Logy(iwnum),Xyscal(2,iwnum),yt)
IF ( Xyscal(4, iwnum).LT.0. ) Xyscal(4, iwnum) = yt
END IF
C
IF ( Logx(iwnum).NE.0 .AND. Xyscal(1, iwnum).LT.0. ) THEN
tmp1 = RMAX
tmp2 = -RMAX
DO igroup = 1, Ngroup
IF ( Ipwin(igroup).EQ.iwnum ) THEN
DO i = 1, Igrpos(2, igroup)
CALL PLTXCC(Y, i, igroup, xt, ndim, iyoff)
IF ( xt(1).NE.NO .AND. xt(1).GT.0 ) THEN
tmp1 = MIN(tmp1, xt(1))
tmp2 = MAX(tmp2, xt(1))
END IF
END DO
END IF
END DO
CALL PLTGAP(tmp1,tmp2,Rgap,Logx(iwnum),Xyscal(1,iwnum),yt)
IF ( Xyscal(3, iwnum).LT.0. ) Xyscal(3,iwnum) = yt
END IF
290 CONTINUE
C---
C Now define scales for the slaves
DO iwnum=1,MXWIN
IF ( Imaster(1,iwnum).GT.0 ) THEN
C Have an X master
Xyscal(1, iwnum) = Xyscal(1,imaster(1,iwnum))
Xyscal(3, iwnum) = Xyscal(3,imaster(1,iwnum))
END IF
IF ( Imaster(2,iwnum).GT.0 ) THEN
C Have a Y master
Xyscal(2, iwnum) = Xyscal(2,imaster(2,iwnum))
Xyscal(4, iwnum) = Xyscal(4,imaster(2,iwnum))
END IF
END DO
C---
RETURN
END
fv5.5/tcltk/plt/edicmn.inc 0000644 0002207 0000036 00000000577 13224715127 014404 0 ustar birby lhea C edicmn.inc
C
C IUP..IEOF are the user-defined control keys.
C IFTYPE is the number returned by FORTYP.
C ICEDIT is <>0 if line editing has been switched on.
C
INTEGER IUP, IDOWN, ILEFT, IRIGHT, IBEG, IEND
INTEGER IWRITE, IERASE, IEOF, IFTYPE, ICEDIT
C
COMMON/EDICMN/ IUP, IDOWN, ILEFT, IRIGHT, IBEG, IEND,
: IWRITE, IERASE, IEOF, IFTYPE, ICEDIT
fv5.5/tcltk/plt/fit.f 0000644 0002207 0000036 00000130273 13224715127 013400 0 ustar birby lhea C FIT.FOR
C- Contains entry points for:
C MODEL
C CPARM
C FRETHA
C FIT
C FITVIS
C UNCERT
C FITLIM
C FNFIT
C MDERIV
C---
BLOCK DATA FITBLK
C---
C Number of terms per model.
C---
C AFT
C---
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
SAVE /FITCMN/
DATA ISTAT/0/
DATA NTER/ 1, 1, 1, 1, 1, 1, 2,
1 3, 3, 3, 3,
2 3, 4,
3 4, 5,
4 3, 3, 2,
5 3, 4, 4, 6, 6, 1,
6 0, 0, 0, 0/
END
C*********
SUBROUTINE MODEL(CBUF, Xmini, Xmaxi, MXPAR, Cmd, Ncmd, Icmd,
: ICOMP, PVAL, PLIM, NTERM)
CHARACTER CBUF*(*)
CHARACTER Cmd(*)*(*)
REAL Xmini(2), Xmaxi(2), PVAL(*), PLIM(3,*)
INTEGER MXPAR, Ncmd, Icmd, NTERM
INTEGER ICOMP(*)
C---
C This routines handles the PLT commands, FReeze, MOdel, NEwpar, THaw,
C and WModel.
C---
C CBUF I Sub-command string
C Xmini I Lower limit for spline models
C Xmaxi I Upper limit for spline models
C MXPAR I Maximun number of terms allowed
C Cmd I PLT CMD array
C Ncmd I Number of valid commands in CMD
C Icmd I/O Number of commands actually used
C ICOMP I/O Component number
C PVAL O Parameter values
C PLIM O Parameter errors/limits
C NTERM I/O Number of parameters
C---
C AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
C
CHARACTER CPARM*4
REAL FNCLOA, FPNUM
INTEGER ISNUM, LENACT
C
CHARACTER CNAM*256, ctmp*256, CTOK*256, ctoku*256
CHARACTER CCOD(MXCOD)*72
SAVE CCOD
CHARACTER CLAB(MXCNUM)*4
REAL TMP, DX
INTEGER I, ICNUM, IE, IER, IFIRST, IHIT, ILOCAL, INEW, IOLD
INTEGER IS, ITMP, IOS
INTEGER K, KP, KP1, LKP
INTEGER LNAM, LOCLAB, ltmp, LTOK, LUN, NCOD, NCTER, NT, NKNOT
SAVE IFIRST
C
EXTERNAL FITBLK
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
C- The model labels.
DATA CLAB/ 'CONS', 'LINR', 'QUAD','CUBI','X4 ','X5 ','POWR',
1 'SIN ', 'GAUS', 'NGAU', 'EXP ',
2 'AEXP', 'BURS',
3 'SBUR', 'PEAR',
4 'WIND', 'KING', 'LN ',
5 'LORE', 'CGAU', 'NCGA', 'EGAU', 'NEGA', 'LY ',
6 'USER', 'SPLN', 'AKIM'/
DATA IFIRST/1/
C---
11 FORMAT(A)
C---
IF(IFIRST.NE.0) THEN
IFIRST=0
CALL UINFO(0, CLAB(MXCNUM-2), NTER(MXCNUM-2))
CALL UPC(CLAB(MXCNUM-2))
END IF
ctmp=CBUF
ltmp=LENACT(ctmp)
KP=0
LUN=0
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
CALL UPC(CTOK)
IF(CTOK(1:1).EQ.'F') THEN
C- Freeze sub-command
CALL FRETHA(-1., ctmp, ltmp, KP, PLIM, NTERM)
RETURN
ELSE IF(CTOK(1:1).EQ.'M') THEN
C- Model sub-command
CALL ALFSKS(ctmp, ltmp, KP)
IF(ctmp(KP+1:KP+1).EQ.'?') THEN
GOTO 890
ELSE IF(ctmp(KP+1:KP+1).EQ.'@') THEN
KP=KP+1
CALL ALF(ctmp, ltmp, KP, CTOK, LTOK)
NTERM=0
CNAM='default'
IF(LTOK.GT.1) CNAM=CTOK(:LTOK)
CALL XTEND(CNAM,'mod')
CALL GETLUN(LUN)
CALL OPENWR(LUN,CNAM,'OLD',' ',' ',0,1,IOS)
IF(IOS.NE.0) GOTO 930
READ(LUN,11,ERR=930,END=930) ctmp
KP=0
ltmp=LENACT(ctmp)
END IF
ELSE IF(CTOK(1:1).EQ.'N') THEN
C- Newpar sub-command
GOTO 500
ELSE IF(CTOK(1:1).EQ.'T') THEN
C- Thaw sub-command
CALL FRETHA( 0., ctmp, ltmp, KP, PLIM, NTERM)
RETURN
ELSE IF(CTOK(1:1).EQ.'W') THEN
C- Wmodel sub-command
IF(CTOK(2:2).EQ.'L') THEN
C WLun LUN
CALL ALF(ctmp, ltmp, KP, CTOK, LTOK)
LUN=FPNUM(CTOK, LTOK, IER)
ctmp='MODEL '
ltmp=6
ILOCAL=0
ELSE
C Wmodel filename
CNAM=' '
CALL ALF(ctmp, ltmp, KP, CNAM, LNAM)
CALL XTEND(CNAM, 'MOD')
CALL GETLUN(LUN)
CALL OPENWR(LUN, CNAM, 'NEW', ' ', 'L', 0, 0, IOS)
IF(IOS.NE.0) THEN
ITMP=LENACT(CNAM)
WRITE(*,*) 'FIT--Error, unable to open file ',CNAM(:ITMP)
CALL FRELUN(LUN)
RETURN
END IF
ctmp=' '
ltmp=0
ILOCAL=1
END IF
NT=1
150 CONTINUE
IF ( ICOMP(NT).LE.MXCNUM ) THEN
C- Standard component
WRITE(ctmp(ltmp+1:),151) CLAB(ICOMP(NT))
151 FORMAT(1X,A)
ltmp=LENACT(ctmp)
ELSE
C- COD file
ITMP=ICOMP(NT)-MXCNUM
WRITE(ctmp(ltmp+1:),151) CCOD(ITMP)(:LENACT(CCOD(ITMP)))
ltmp=LENACT(ctmp)
END IF
C- Special treatment for components that require a parameter
IF ( ICOMP(NT).EQ.MXCNUM-1 ) THEN
C- Spline
WRITE(ctmp(ltmp+1:),161) NTER(ICOMP(NT))/2
161 FORMAT(1X,I3)
ltmp=ltmp+5
ELSE IF ( ICOMP(NT).EQ.MXCNUM ) THEN
C- Akima
WRITE(ctmp(ltmp+1:),161) NTER(ICOMP(NT))/2
ltmp=ltmp+5
END IF
NT=NT+NTER(ICOMP(NT))
IF(NT.LE.NTERM) GOTO 150
WRITE(LUN,11) ctmp(:ltmp)
DO I=1,NTERM
CTOK=CPARM(ICOMP,I,NTERM)
WRITE(ctmp,*) PVAL(I),PLIM(1,I),PLIM(2,I),PLIM(3,I)
ltmp = LENACT(ctmp)
IF ( ltmp.LT.40 ) THEN
ctmp(ltmp:40)=' '
ltmp = 40
END IF
ctmp(ltmp+1:ltmp+2)=' !'
ltmp = ltmp+2
CALL CRAMIF(i,4,ctmp,ltmp)
WRITE(LUN,11) ctmp(:ltmp)//' '//ctok(1:2)
END DO
IF(PVAL(NTERM+1).GE.0.) THEN
ctmp='! WVAR='
ltmp=8
CALL CRAMF(PVAL(NTERM+1),ctmp,ltmp)
WRITE(LUN,11) ctmp(:ltmp)
ctmp='! NBIN='
ltmp=8
CALL CRAMF(PVAL(NTERM+2),ctmp,ltmp)
WRITE(LUN,11) ctmp(:ltmp)
END IF
IF(ILOCAL.NE.0) THEN
CLOSE(UNIT=LUN)
CALL FRELUN(LUN)
END IF
RETURN
ELSE IF ( LTOK.LE.0 ) THEN
GOTO 890
ELSE
RETURN
END IF
C---
C- Fall through to start reading a model
C- Reset all of COD's internal pointers.
TMP=FNCLOA(+1,0,0,0.)
NTERM=0
NCOD=0
C- Get component token
200 CONTINUE
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF ( LTOK.LE.0 ) THEN
PVAL(NTERM+1)=-1.
GOTO 500
END IF
IF ( CTOK(1:1).EQ.'/' ) RETURN
CTOKU = CTOK
CALL UPC(CTOKU)
LOCLAB=1
IF(2.LE.LTOK .AND. LTOK.LE.4) THEN
C- Built-in components can only be specified with 2-4 characters.
DO ICNUM=1,MXCNUM
IF ( CLAB(ICNUM)(1:LTOK).EQ.CTOKU(1:LTOK) ) GOTO 250
LOCLAB=LOCLAB+NTER(ICNUM)
END DO
END IF
C- Now try a COD file
DO I=1,NCOD
ctok = ccod(i)(:ltok)
CALL UPC(ctok)
IF ( ctok(1:LTOK).EQ.CTOKU(1:LTOK)) THEN
ICNUM=MXCNUM+I
GOTO 350
END IF
END DO
KP1=0
CALL CODFIL(CTOK,LTOK,KP1,NCTER,IER)
IF ( IER.EQ.0 ) THEN
IF ( NCOD.GE.MXCOD ) THEN
WRITE(*,231) MXCOD
231 FORMAT(' MODEL--Can only use',I6,' COD files.')
NTERM=0
RETURN
END IF
NCOD=NCOD+1
ICNUM=MXCNUM+NCOD
CCOD(NCOD)=CTOK
NTER(ICNUM)=NCTER
GOTO 350
END IF
C---
C- Typo
WRITE(*,211) CTOK(1:LTOK)
211 FORMAT(' Illegal component: "',A,'"')
GOTO 890
C---
C- Get number of terms for components with variable number of terms.
250 CONTINUE
IF ( ICNUM.EQ.MXCNUM-1 .OR. ICNUM.EQ.MXCNUM ) THEN
C- Spline or Akima
LKP=KP
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF(ISNUM(CTOK,LTOK).NE.0) THEN
NKNOT=FPNUM(CTOK,LTOK,IER)
ELSE
KP=LKP
END IF
IF(NKNOT.LE.1) NKNOT=2
NTER(ICNUM)=2*NKNOT
IF ( ICNUM.EQ.MXCNUM-1 ) THEN
CALL SPLIM(PVAL, PLIM, -1, NTER(ICNUM))
ELSE
CALL AKLIM(PVAL, PLIM, -1, NTER(ICNUM))
ENDIF
NKNOT=NTER(ICNUM)/2
END IF
C---
C- Make sure we will not overflow the parameter arrays
350 CONTINUE
IF ( NTERM+NTER(ICNUM).GT.MXPAR ) THEN
WRITE(*,351) MXPAR
351 FORMAT(' MODEL--Can only contain',I6,' terms.')
NTERM=0
RETURN
END IF
C---
C- Fill the ICOMP array
DO I=1,NTER(ICNUM)
ITMP=NTERM+I
C- If parameter is not the same as the old then unfreeze.
IF ( ICOMP(ITMP).NE.ICNUM ) THEN
PLIM(1,ITMP)=0.
END IF
ICOMP(ITMP)=ICNUM
END DO
C---
C- Special initial conditions for Spline or Akima components
IF ( ICNUM.EQ.MXCNUM-1 .OR. ICNUM.EQ.MXCNUM ) THEN
XMIN(1) = Xmini(1)
XMAX(1) = Xmaxi(1)
XMIN(2) = Xmini(2)
XMAX(2) = Xmaxi(2)
IF ( XMIN(1).EQ.XMAX(1) ) XMAX(1) = XMIN(1)+1.
DX=(XMAX(1)-XMIN(1))/(NKNOT-1)
DO I=1,NKNOT
C- To start, evenly distribute X-locations of knots and freeze
ITMP=NTERM+I
PVAL(ITMP) =XMIN(1)+DX*(I-1)
PLIM(1,ITMP)=-1.
PLIM(1,ITMP+NKNOT)=0.
END DO
END IF
C---
C- Increment number of terms and loop
NTERM=NTERM+NTER(ICNUM)
GOTO 200
C---
C-
500 IF(NTERM.LE.0) GOTO 890
C---
C- Now read initial parameter values.
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF ( LTOK.GT.0 ) THEN
IS=FPNUM(CTOK,LTOK,IER)
IE=IS
ELSE
IS=1
IE=NTERM
END IF
IS=MIN(MAX(IS,1),NTERM)
IE=MIN(MAX(IE,1),NTERM)
DO I=IS,IE
IF ( KP.GE.ltmp ) THEN
KP=0
IF ( LUN.GT.0 ) THEN
C Reading a model file
510 CONTINUE
READ(LUN,11,ERR=930,END=930) ctmp
ltmp=LENACT(ctmp)
C Skip lines starting with !
IF ( ctmp(1:1).EQ.'!') GOTO 510
ELSE
520 CONTINUE
IF ( icmd.GE.0 .AND. icmd.LT.Ncmd ) THEN
C Still be reading from the PLT CMD array
IF ( LENACT(Cmd(icmd+1)).LE.0 ) THEN
icmd = icmd+1
GOTO 520
END IF
CALL STWARN(1)
CALL LDBUF1(Cmd(icmd+1),Ier)
icmd = icmd+1-Ier
ELSE
C No other place to read, must prompt the user directly.
CTOK=CPARM(ICOMP,I,NTERM)
WRITE(*,521) I,CTOK,PVAL(I),(PLIM(K,I),K=1,3)
521 FORMAT(I3,' ',A2,': VAL(',1PG11.4,'), SIG(',G11.4,
: '), PLO(',G11.4,'), PHI(',G11.4,')?')
END IF
CALL GTBUF(' ',IER)
IF ( IER.LT.0 ) GOTO 700
CALL GTREST(ctmp,ltmp)
CALL ALFSKS(ctmp, ltmp, kp)
IF ( ctmp(kp+1:kp+1).EQ.'"' ) kp = kp + 1
END IF
END IF
C Get parameter value
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF(LTOK.GT.0) THEN
TMP=FPNUM(CTOK,LTOK,IER)
IF(PVAL(I).NE.TMP) PVAL(NTERM+1)=-1.
PVAL(I)=TMP
END IF
C Get sigma or constraint
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF(LTOK.GT.0) THEN
IOLD=NINT(PLIM(1,I))
PLIM(1,I)=FPNUM(CTOK,LTOK,IER)
INEW=NINT(PLIM(1,I))
IF(INEW.LT.-1) THEN
C Constrained freeze, ensure factor is correct.
PLIM(2,I)=1.0
ELSE IF(INEW.GE.0 .AND. IOLD.LT.-1) THEN
C Thawed a constrainded parameter. Lower limit is meaningless, so reset.
PLIM(2,I)=0.0
END IF
END IF
C Get lower limit or factor
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF(LTOK.GT.0) PLIM(2,I)=FPNUM(CTOK,LTOK,IER)
C Get upper limit
CALL ALF(ctmp,ltmp,KP,CTOK,LTOK)
IF(LTOK.GT.0) PLIM(3,I)=FPNUM(CTOK,LTOK,IER)
IF ( ctmp(kp+1:kp+1).EQ.'!' ) kp=ltmp
END DO
C---
C- For constrained parameters, force parameter to be equal to another
C- valid parameter.
700 CONTINUE
DO i=1,NTERM
C Avoid integer overflows on numbers with BIG sigmas.
IF(PLIM(1,i).LT.0.) THEN
IF(NINT(-PLIM(1,i)).GT.1) THEN
PLIM(1,i)=MIN(MAX(-FLOAT(NTERM),PLIM(1,i)),-2.)
C Parameter cannot be a constant times itself, just freeze it.
IF(NINT(PLIM(1,i)).EQ.-i) THEN
PLIM(1,i)=-1.
PLIM(2,i)=0.
END IF
END IF
END IF
END DO
C-
CALL FITLIM(ICOMP, PVAL, PLIM, NTERM, IHIT)
IF(LUN.NE.0) THEN
CLOSE(UNIT=LUN)
CALL FRELUN(LUN)
END IF
RETURN
C---
890 WRITE(*,891) (CLAB(K),K=1,MXCNUM)
891 FORMAT(' Possible components are:'/(9(2X,A4)))
RETURN
C-
930 WRITE(*,931)
931 FORMAT(' Unable to Open (or Read) full model file.')
CLOSE(UNIT=LUN)
CALL FRELUN(LUN)
RETURN
C---
END
C*********
CHARACTER*(*) FUNCTION CPARM(ICOMP, IPAR, NTERM)
INTEGER ICOMP(*), IPAR, NTERM
C---
C Find the label associated with parameter IPAR.
C---
C ICOMP I
C IPAR I
C NTERM I
C---
C 1990-Mar-02 - New routine [AFT]
C---
INTEGER MXTERM
PARAMETER (MXTERM=68)
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
C
CHARACTER CTLAB(MXTERM)*2
INTEGER I, ICNUM, IOFF, ITMP, LABPOS
C
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
C The (first three) term labels.
DATA CTLAB/'CO', 'LI', 'QU', 'CU', 'X4', 'X5', 'IN','PN',
1 'PE','PH','SN', 'GC','GW','GN', 'Gc', 'Gw', 'Gn',
2 'EC','EW','EN', 'EC','EW','EN', 'ST','PT','DT','BN',
3 'TS','RR','DT','BN', 'K ','X0','A1','M1','M2',
4 'T1','T2','LE', 'RC','IN','S0', 'XC','NL',
5 'LC','LW','LN', 'Xc','Yc','Gw','Gn', 'Xc','Yc','Gw','Gn',
6 'Xc','Sx','Yc','Sy','TH','Gn',
7 'Xc','Sx','Yc','Sy','TH','Gn', 'Ly'/
C---
IF(IPAR.EQ.NTERM+1) THEN
CPARM='WV'
RETURN
ELSE IF(IPAR.GT.NTERM) THEN
CPARM=' N'
RETURN
END IF
C---
C Must first scan through to find out the parameter offset into the
C current component.
IOFF=1
120 IF(IOFF+NTER(ICOMP(IOFF)).LE.IPAR) THEN
IOFF=IOFF+NTER(ICOMP(IOFF))
GOTO 120
END IF
IOFF=IPAR-IOFF
C
ICNUM=ICOMP(IPAR)
IF(ICNUM.LE.MXCNUM-3) THEN
LABPOS=1
DO I=1,ICNUM-1
LABPOS=LABPOS+NTER(I)
END DO
CPARM=CTLAB(LABPOS+IOFF)
ELSE IF(ICNUM.EQ.MXCNUM-2) THEN
CALL UINFO(IOFF+1, CPARM, ITMP)
ELSE IF(ICNUM.EQ.MXCNUM-1) THEN
IF(IOFF.LT.NTER(ICNUM)/2) THEN
CPARM='SX'
ELSE
CPARM='SY'
END IF
ELSE IF(ICNUM.EQ.MXCNUM) THEN
IF(IOFF.LT.NTER(ICNUM)/2) THEN
CPARM='AX'
ELSE
CPARM='AY'
END IF
ELSE IF(ICNUM.GT.MXCNUM) THEN
CPARM='P'//CHAR(ICHAR('0')+MOD(IOFF+1,10))
END IF
C---
RETURN
END
C*********
SUBROUTINE FRETHA(PARVAL, Ctmp, Ltmp, KP, PLIM, NTERM)
REAL PARVAL, PLIM(3,*)
INTEGER Ltmp, KP, NTERM
CHARACTER Ctmp*(*)
C---
C Set PLIM(IPAR,1)=PARVAL for all IPAR values listed in Ctmp.
C---
C PARVAL I The value to set.
C Ctmp I
C Ltmp I
C KP I/O
C PLIM I/O
C NTERM I
C---
C 1989-Oct-02 - [AFT]
C---
CHARACTER CTOK*32
INTEGER I, IHI, ILO, LTOK, IER
C---
110 CALL ALF(Ctmp, Ltmp, KP, CTOK, LTOK)
IF(LTOK.LE.0) RETURN
CALL IRANGE(CTOK, LTOK, 1, 0, ILO, IHI, IER)
IF(ILO.LE.0 .OR. IHI.GT.NTERM) THEN
WRITE(*,*) ILO,'--Illegal parameter'
RETURN
END IF
DO I=ILO, IHI
PLIM(1,I)=PARVAL
END DO
GOTO 110
END
C*********
SUBROUTINE FIT(CBUF, IFIT, Y, MXROW, Ngroup, ICWIN,
: Ipwin, IPYER, IWIN, IGRPOS, XYSCAL,
: ICOMP, PVAL, PLIM, NTERM)
CHARACTER CBUF*(*)
REAL Y(*), XYSCAL(4,*), PVAL(*), PLIM(3,*)
INTEGER IFIT, MXROW, Ngroup, ICWIN
INTEGER Ipwin(*), IPYER(*), IWIN(*), IGRPOS(3,*)
INTEGER ICOMP(*), NTERM
C---
C This routine executes the PLT commands, FIT and FIT ERROR.
C---
C CBUF I The string containing possible sub-commands.
C IFIT I/O The number of the group fitted.
C Y I
C MXROW I
C Ngroup I
C Icwin I/O The (first) window containing the plot group being fitted.
C Ipwin
C IPYER I
C Iwin
C IGRPOS I Need to pass entire array since Ifit can change
C XYSCAL I
C ICOMP I
C PVAL I/O
C PLIM I
C NTERM I
C---
C AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
REAL FPNUM
INTEGER ISNUM, LENACT
C
CHARACTER CTOK*32
REAL FDEL
SAVE FDEL
REAL CHI, CHIM, PLO, PHI, xt(2)
INTEGER IEGOOD, IHIP, ILOP, ISGOOD, NITER
SAVE IEGOOD, IHIP, ILOP, ISGOOD, NITER
INTEGER I, ICNT, IDONE, IER
INTEGER IPAR, ITMP, IX, iy0
INTEGER KP, LB, LTOK, ndim
C
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
DATA NITER/10/,ILOP,IHIP/1,1/
DATA FDEL/2.7/
C---
IF ( NTERM.LE.0 ) THEN
WRITE(*,*) 'FIT--Error, No model defined.'
RETURN
END IF
C---
C Scan for sub-commands
LB=LENACT(CBUF)
KP=0
IDONE=0
CALL ALF(CBUF, LB, KP, CTOK, LTOK)
100 CONTINUE
CALL UPC(CTOK)
IF(CTOK(1:1).EQ.'U') THEN
C 'UNcertainty' subcommand
IF ( istat.NE.0 ) THEN
WRITE(*,*) 'Using likelihood.'
END IF
GOTO 300
ELSE IF(CTOK(1:1).EQ.'I') THEN
C 'Iteration' sub-command
CALL ALF(CBUF, LB, KP, CTOK, LTOK)
IF(LTOK.GT.0) THEN
NITER=NINT(FPNUM(CTOK,LTOK,IER))
END IF
ELSE IF(CTOK(1:1).EQ.'S') THEN
C 'Statistic' sub-command
CALL ALF(CBUF, LB, KP, CTOK, LTOK)
CALL UPC(CTOK)
IF(LTOK.EQ.0) THEN
ISTAT=0
ELSE IF(CTOK(1:1).EQ.'C') THEN
ISTAT=0
WRITE(*,*) 'Using chi^2.'
ELSE IF(CTOK(1:1).EQ.'M') THEN
ISTAT=1
END IF
ELSE IF(ISNUM(CTOK,LTOK).NE.0) THEN
C # sub-command
ITMP=FPNUM(CTOK,LTOK,IER)
C%%%
C This allows user to ask to fit defined groups, but the fitting engine
C only fits the original data.
IF(ITMP.GT.0 .AND. ITMP.LE.Ngroup .AND.
: igrpos(1,itmp).GE.0 ) THEN
C%%%
IFIT=ITMP
ELSE
WRITE(*,*) 'FIT--',itmp,' is not a valid data group.'
END IF
ICWIN=IWIN(IFIT)
CALL PLTXCC(Y, 1, ifit, xt, ndim, itmp)
XMIN(1)=MIN(XYSCAL(1,ICWIN),XYSCAL(3,ICWIN))
XMAX(1)=MAX(XYSCAL(1,ICWIN),XYSCAL(3,ICWIN))
XMIN(2)=MIN(XYSCAL(2,ICWIN),XYSCAL(4,ICWIN))
XMAX(2)=MAX(XYSCAL(2,ICWIN),XYSCAL(4,ICWIN))
WRITE(*,231) IFIT,XMIN(1),XMAX(1)
IF ( ndim.GT.1) WRITE(*,241) XMIN(2),XMAX(2)
CALL FITIT(Y, IPYER(IFIT), MXROW, ifit,
: IGRPOS(1,IFIT), IGRPOS(2,IFIT), Xmin, Xmax, ISGOOD, IEGOOD,
: NITER, ISTAT, ICOMP, PVAL, PLIM, NTERM, CHI)
IDONE=1
END IF
CALL ALF(CBUF, LB, KP, CTOK, LTOK)
IF(LTOK.GT.0) GOTO 100
IF ( istat.NE.0 ) THEN
WRITE(*,*) 'Using likelihood.'
END IF
C---
IF ( IDONE.EQ.0 ) THEN
CALL FITVIS(Ipwin, Ngroup, IFIT)
ICWIN=IWIN(IFIT)
CALL PLTXCC(Y, 1, ifit, xt, ndim, itmp)
XMIN(1)=MIN(XYSCAL(1,ICWIN),XYSCAL(3,ICWIN))
XMAX(1)=MAX(XYSCAL(1,ICWIN),XYSCAL(3,ICWIN))
XMIN(2)=MIN(XYSCAL(2,ICWIN),XYSCAL(4,ICWIN))
XMAX(2)=MAX(XYSCAL(2,ICWIN),XYSCAL(4,ICWIN))
WRITE(*,231) IFIT,XMIN(1),XMAX(1)
231 FORMAT(' Fitting group',I4,', from',1PG11.3,' to',G11.3)
IF ( ndim.GT.1) WRITE(*,241) XMIN(2),XMAX(2)
241 FORMAT(' And bounded in Y by',1PG11.3,' to',G11.3)
CALL FITIT(Y, IPYER(IFIT), MXROW, IFIT,
: IGRPOS(1,IFIT), IGRPOS(2,IFIT), Xmin, Xmax, ISGOOD, IEGOOD,
: NITER, ISTAT, ICOMP, PVAL, PLIM, NTERM, CHI)
END IF
RETURN
C---
C Come here to compute uncertainties.
C Read up to three optional numbers.
300 CONTINUE
ICNT=0
DO I=1,3
CALL ALF(CBUF,LB,KP,CTOK,LTOK)
IF(LTOK.LE.0) GOTO 340
IX=INDEX(CTOK(:LTOK),'.')
IF(IX.GT.0) THEN
C Reset default delta CHI^2
FDEL=FPNUM(CTOK,LTOK,IER)
ELSE
C Reset parameter range over which to determine errors.
ITMP=FPNUM(CTOK,LTOK,IER)
ITMP=MIN( MAX(1,ITMP), NTERM)
IF(ICNT.EQ.0) THEN
ILOP=ITMP
ELSE
IF(ITMP.GT.ILOP) THEN
IHIP=ITMP
ELSE
IHIP=ILOP
ILOP=ITMP
END IF
END IF
ICNT=ICNT+1
END IF
END DO
340 IF(ICNT.EQ.1) IHIP=ILOP
C---
C For each parameter in the given range. Find the error.
CHIM=PVAL(NTERM+1)
NITER=10
iy0=IGRPOS(1,IFIT)
DO IPAR=ILOP,IHIP
CALL UNCERT(Y, Ifit, iy0, IPYER(IFIT), MXROW, Xmin, Xmax,
& ISGOOD, IEGOOD, 1, ISTAT, ICOMP, PVAL, PLIM, NTERM, CHIM,
: IPAR, FDEL, PLO, PHI, IER)
IF(IER.GT.0) THEN
IF(IER.EQ.1) THEN
WRITE(*,371) CHIM
371 FORMAT(' New minimum found. CHI^2=',1PG10.4)
END IF
RETURN
END IF
WRITE(*,411) IPAR,FDEL,PLO,PHI
411 FORMAT(' Parameter ',I3,', Delta CHI^2=',1PG11.4,2G12.4)
END DO
C---
RETURN
END
C*********
SUBROUTINE FITVIS(Ipwin, Ngroup, IFIT)
INTEGER Ipwin(*), Ngroup, IFIT
C---
C Return the plot group to actually fit in Ifit. This will be unchanged
C unless Ifit is 0 (not defined) or the group being fitted is no longer
C being plotted (i.e., was colored off). In this case, find the smallest
C number corresponding to a plot group this is visible.
C---
C Ipwin I >0 group is being plotted, <=0 otherwise
C Ngroup I
C IFIT I/O
C---
C 1990-Mar-07 - [AFT]
C---
INTEGER ig
C---
IF ( IFIT.EQ.0 .OR. Ipwin(IFIT).LE.0 ) THEN
DO ig=1,Ngroup
IF ( Ipwin(ig).GT.0 ) THEN
IFIT=ig
GOTO 230
END IF
END DO
C Everything is colored of. Guess a random group.
IFIT = 2
END IF
C
230 CONTINUE
RETURN
END
C*********
SUBROUTINE UNCERT(Y, Igroup, iy0, LERY, MXROW, Xmin, Xmax,
& ISGOOD, IEGOOD, ICHAT, ISTAT, ICOMP, PVAL, PLIM, NTERM, CHIM,
: IPAR, VVREQ, PLO, PHI, IER)
INTEGER NTERM
REAL Y(*), Xmin(*), Xmax(*), PVAL(*), PLIM(3,*)
REAL CHIM, VVREQ, PLO, PHI
INTEGER Igroup, iy0, LERY, MXROW, ISGOOD, IEGOOD
INTEGER ICHAT, ISTAT, ICOMP(NTERM)
INTEGER IPAR, IER
C---
C Finds delta chi^2.
C---
C Y I
C Igroup I The group number
C MXROW I
C LERY I
C ISGOOD I
C IEGOOD I
C ICHAT I
C PVAL I/O Parameter values at minimum.
C PLIM I/O Bevington's errors at minimum.
C CHIM I Minimun chi square.
C IPAR I Index of parameter to find error.
C VVREQ I Requested value of delta chi squared.
C PLO O Low value of the parameter.
C PHI O Hi value for parameter
C IER O =0 Value found,
C =1 New minimum found.
C =2 Model insensitive to changes in some par.
C =3 Parameter frozen.
C <0 Gave up at least once.
C---
C AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXPAR
PARAMETER (MXPAR=120)
C
REAL PTRY(MXPAR), SAVSIG(MXPAR)
REAL CHI, DELCO, DELP, FUDGE, P1, P2
REAL V1, V2, VNEW, VREQ
INTEGER I, ICNT, IFL, IHIT, NITER, NDOF, NFIT, NFPAR
C
DATA NITER/20/
C---
IF ( PVAL(NTERM+1).LT.0.0 ) THEN
C User has not done a Fit hence chi^2 is not defined.
WRITE(*,*) 'UNCERT--Must do a Fit before UNcertainty.'
IER=3
RETURN
END IF
C
IF(PLIM(1,IPAR).LT.0.) THEN
WRITE(*,*)
: 'UNCERT--Not allowed to find error of frozen parameter.'
IER=3
RETURN
END IF
IER=0
FUDGE=1.0
IF ( LERY.EQ.0 .AND. Istat.EQ.0) THEN
C---
C No errors, must compute fudge factor that makes reduced CHI^2
C equal to 1.0.
NFPAR=0
DO I=1,NTERM
IF(PLIM(1,I).GE.0) NFPAR=NFPAR+1
END DO
NFIT=PVAL(NTERM+2)
NDOF=NFIT-NFPAR
IF(CHIM.GT.0.) FUDGE=(NFIT-NFPAR)/CHIM
WRITE(*,131) FUDGE
131 FORMAT(' W-VAR is being multiplied by',1PG9.2,
: ' to convert to Chi^2')
END IF
VREQ=SQRT(VVREQ)
DELP=-VREQ*PLIM(1,IPAR)
IF(ICHAT.GT.0) WRITE(*,181)
181 FORMAT(' Delta parm Delta Chi^2')
C---
DO I=1,NTERM
PTRY(I)=PVAL(I)
SAVSIG(I)=PLIM(1,I)
END DO
PLIM(1,IPAR)=-1.
IFL=1
C---
300 CONTINUE
ICNT=0
P1=0.
V1=0.
C---
350 CONTINUE
PTRY(IPAR)=PVAL(IPAR)+DELP
IF(PLIM(2,IPAR).LT.PLIM(3,IPAR)) THEN
C Hard limit
PTRY(IPAR)=MIN( MAX(PLIM(2,IPAR),PTRY(IPAR)) ,PLIM(3,IPAR))
END IF
CALL FITLIM(ICOMP, PTRY, PLIM, NTERM, IHIT)
CALL CURFIT(Y, Igroup, iy0, LERY, MXROW, ISGOOD, IEGOOD,
: Xmin, Xmax, -1, NITER, ISTAT, ICOMP, 0, NTERM,
& 0.0, PTRY, PLIM, CHI)
IF(CHI.LT.0.) THEN
C Model insensitive to changes in parameter value.
DO I=1,NTERM
PLIM(1,I)=SAVSIG(I)
END DO
IER=2
RETURN
END IF
C
DELCO=(CHI-CHIM)*FUDGE
IF(ICHAT.GT.0) WRITE(*,361) DELP,DELCO
361 FORMAT(1X,1PG10.3,4X,G10.3)
IF(DELCO.LT.0.) THEN
C Found a new lower value of Chi^2, return new parameters to user.
DO I=1,NTERM
PVAL(I)=PTRY(I)
END DO
PLIM(1,IPAR)=0.
CHIM=CHI
IER=1
RETURN
END IF
IF(ABS(DELCO-VVREQ).LT..01) GOTO 400
VNEW=SQRT(DELCO)
IF(ICNT.EQ.0) THEN
P2=DELP
V2=VNEW
ELSE
IF(VNEW.LT.VREQ) THEN
P1=DELP
V1=VNEW
ELSE
P2=DELP
V2=VNEW
END IF
END IF
IF(ABS(V2-V1).GT.1.E-12 .AND. ICNT.LT.10) THEN
DELP=P1+(VREQ-V1)*(P2-P1)/(V2-V1)
IF(IFL.NE.0) THEN
IF(DELP.GT.0.) GOTO 390
ELSE
IF(DELP.LT.0.) GOTO 390
END IF
IF(ICNT.GT.5) THEN
IF(V1.EQ.0. ) DELP= .9*DELP
IF(V2.LT.VREQ) DELP=1.1*DELP
END IF
ICNT=ICNT+1
GOTO 350
END IF
390 CONTINUE
WRITE(*,391)
391 FORMAT(' UNCERT--Give up.')
IER=-1
C---
400 CONTINUE
IF(IFL.NE.0) THEN
IFL=0
PLO=PTRY(IPAR)
DELP=-DELP
GOTO 300
END IF
PHI=PTRY(IPAR)
C Restore the original sigmas.
DO I=1,NTERM
PLIM(1,I)=SAVSIG(I)
END DO
C Note, splines keep internal parameters that need to be restored.
CALL FITLIM(ICOMP, PVAL, PLIM, NTERM, IHIT)
RETURN
END
C*********
SUBROUTINE FITLIM(ICOMP, PVAL, PLIM, NTERM, IHIT)
INTEGER NTERM
INTEGER ICOMP(NTERM)
REAL PVAL(NTERM), PLIM(3,NTERM)
C---
C This routine should be called just after parameters have been
C changed to make sure the parameters are in legal bounds.
C---
C ICOMP I Component defination.
C PVAL I/O Parameter values, can be altered to meet limits.
C PLIM I The limit array.
C IHIT O If non-zero, is the number of a parameter that
C -was altered.
C---
C AFT
C---
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
C
REAL tmp
INTEGER I, IACOMP, IHIT, IX, NT
C
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
C---
IHIT=0
NT=1
C---
C Do the general parameter ajustments.
100 IACOMP=ICOMP(NT)
DO 110 I=NT,NT+NTER(IACOMP)-1
C Avoid integer overflows on numbers with BIG sigmas
IF(PLIM(1,I).LT.0.) THEN
IX=NINT(-PLIM(1,I))
IF(IX.GT.1) THEN
IF(PLIM(2,I).NE.0.) THEN
C Constrained to be a constant times another parameter.
PVAL(I)=PLIM(2,I)*PVAL(IX)
ELSE
C Constrained to be a constant added to another parameter.
PVAL(I)=PLIM(3,I)+PVAL(IX)
END IF
END IF
ELSE IF(PLIM(2,I).LT.PLIM(3,I)) THEN
C Hard limit
IF(PVAL(I).LT.PLIM(2,I)) THEN
IHIT=I
PVAL(I)=PLIM(2,I)
ELSE IF(PVAL(I).GT.PLIM(3,I)) THEN
IHIT=I
PVAL(I)=PLIM(3,I)
END IF
END IF
110 CONTINUE
C Now check for special cases
GOTO (890,890,890,890,890,890,890,890,320,320,890,890,890,890,
: 890,890,890,890,890,650,650,660,660,890,
: 800,820,860,890) IACOMP
C
C- Gaussian/Ngaus (force width to be positive)
320 CONTINUE
PVAL(NT+1)=ABS(PVAL(NT+1))
IF ( Pval(nt+1).EQ.0.0 ) Pval(nt+1) = 1.0E-6
GOTO 890
C
C- CGaus/NCgaus (force width to be positive)
650 CONTINUE
Pval(nt+2)=ABS(Pval(nt+2))
IF ( Pval(nt+1).EQ.0.0 ) Pval(nt+1) = 1.0E-6
GOTO 890
C
C- EGaus/NEgaus (force width to be positive)
660 CONTINUE
C Sigma cannot be negative nor zero.
Pval(nt+1)=ABS(Pval(nt+1))
IF ( Pval(nt+1).EQ.0.0 ) Pval(nt+1) = 1.0E-6
Pval(nt+3)=ABS(Pval(nt+3))
IF ( Pval(nt+3).EQ.0.0 ) Pval(nt+3) = 1.0E-6
C Require sigx to be larger than sigy
IF ( Pval(nt+3).GT.Pval(nt+1) ) THEN
C But only if sigx, sigy, and theta are all free
IF ( Plim(1,nt+1).GE.0.0 .AND. Plim(1,nt+3).GE.0.0 .AND.
& Plim(1,nt+4).GE.0.0 ) THEN
tmp = Pval(nt+3)
Pval(nt+3) = Pval(nt+1)
Pval(nt+1) = tmp
Pval(nt+4) = Pval(nt+4)+90.
END IF
END IF
C Make sure angle is in range -90 +90
tmp = MOD(Pval(nt+4)+90.,180.)
IF ( tmp.LT.0.0 ) tmp=tmp+180.
Pval(nt+4)=tmp-90.
GOTO 890
C
C- User model.
800 CALL ULIMIT(PVAL, PLIM, NT, NTER(IACOMP))
GOTO 890
C
C- SPLN Spline
820 CALL SPLIM(PVAL, PLIM, NT, NTER(IACOMP))
GOTO 890
C
C- AKIMA model.
860 CALL AKLIM(PVAL, PLIM, NT, NTER(IACOMP))
GOTO 890
C---
890 NT=NT+NTER(IACOMP)
IF(NT.LE.NTERM) GOTO 100
C---
RETURN
END
C*********
REAL FUNCTION FNFIT(Xt, ICOMP, PVAL, NTERM)
INTEGER ICOMP(*), NTERM
REAL Xt(2), PVAL(NTERM)
C---
C Compute the function value.
C---
C Xt I The (possibly 2 dimensional) independent variable
C ICOMP I
C PVAL(*) I
C PLIM(3,*) I
C---
C AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
REAL FNAKIM, FNCOD, FNSP, UFNY
C
REAL A2, ca, DEM, EX, FAC, P1, sa, T, T1LOG, T2LOG
REAL TC, TMP, TT, X, X1, X2, XC, xs, y, ys, z2
INTEGER IACOMP, IER, NT
C
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
REAL rtd
DATA rtd/57.2957795/
C---
X=Xt(1)
Y=Xt(2)
C
FNFIT=0.
NT=1
100 CONTINUE
IACOMP=ICOMP(NT)
GOTO (200,210,220,230,240,250,260,300,320,320,360,360,400,450,
: 500,550,600,620,640,650,650,660,660,670,
: 800,820,860,880) IACOMP
C- CONS
200 FNFIT=FNFIT+PVAL(NT)
GOTO 890
C- LINR
210 FNFIT=FNFIT+PVAL(NT)*X
GOTO 890
C- QUAD
220 FNFIT=FNFIT+PVAL(NT)*X*X
GOTO 890
C- CUBI
230 FNFIT=FNFIT+PVAL(NT)*X*X*X
GOTO 890
C- X4
240 X2=X*X
FNFIT=FNFIT+PVAL(NT)*X2*X2
GOTO 890
C- X5
250 X2=X*X
FNFIT=FNFIT+PVAL(NT)*X2*X2*X
GOTO 890
C- POWR
260 IF(X.GT.0.) THEN
IF(PVAL(NT+1).GT.0.) THEN
TMP=PVAL(NT)*LOG(X)+LOG( PVAL(NT+1))
TMP=MIN(MAX(-70.,TMP),70.)
FNFIT=FNFIT+EXP(TMP)
ELSE IF(PVAL(NT+1).LT.0.) THEN
TMP=PVAL(NT)*LOG(X)+LOG(-PVAL(NT+1))
TMP=MIN(MAX(-70.,TMP),70.)
FNFIT=FNFIT-EXP(TMP)
END IF
END IF
GOTO 890
C- SIN
300 IF(PVAL(NT).NE.0.) FNFIT=FNFIT+PVAL(NT+2)*SIN((X-PVAL(NT+1))*
: 6.28318531/PVAL(NT))
GOTO 890
C- GAUS/NGAU
320 CONTINUE
xs = (X-PVAL(NT))/PVAL(NT+1)
ex = 0.
IF ( ABS(xs).LT.12.0 ) ex = EXP(-xs*xs/2.)
IF ( IACOMP.EQ.9 ) THEN
C GAus
FNFIT=FNFIT+PVAL(NT+2)*ex
ELSE
C NGaus
FNFIT=FNFIT+PVAL(NT+2)*ex/(2.50662827*PVAL(NT+1))
END IF
GOTO 890
C- EXP and AEXP
360 xs=0.
IF ( PVAL(NT+1).NE.0. ) xs=(X-PVAL(NT))/PVAL(NT+1)
IF ( IACOMP.EQ.12 ) xs=ABS(xs)
EX=0.
IF ( ABS(xs).LT.80. ) EX=EXP(-xs)
FNFIT=FNFIT+PVAL(NT+2)*EX
GOTO 890
C- BURS
400 xs=0.
IF ( X.GT.PVAL(NT) ) THEN
IF ( X.LT.PVAL(NT+1) ) THEN
FNFIT=FNFIT+PVAL(NT+3)*(X-PVAL(NT))/(PVAL(NT+1)-PVAL(NT))
ELSE
IF ( PVAL(NT+2).NE.0.) xs=(X-PVAL(NT+1))/PVAL(NT+2)
EX=0.
IF ( ABS(xs).LT.70. ) EX=EXP(-xs)
FNFIT=FNFIT+PVAL(NT+3)*EX
END IF
END IF
GOTO 890
C- SBUR
450 T=X-PVAL(NT)
IF(T.GT.0) THEN
FAC=1.
IF(PVAL(NT+1).NE.0.) FAC=2.718281828/ABS(PVAL(NT+1)*PVAL(NT+2))
TC=LOG(FAC*T)
P1=PVAL(NT+1)*TC-T/PVAL(NT+2)
EX=0.
IF(ABS(P1).LT.80.) EX=EXP(P1)
FNFIT=FNFIT+PVAL(NT+3)*EX
END IF
GOTO 890
C- PEAR
500 A2=PVAL(NT+2)*PVAL(NT+4)/PVAL(NT+3)
X1=(X-PVAL(NT+1))/PVAL(NT+2)
X2=(X-PVAL(NT+1))/A2
IF ( -1.0.LT.X1 .AND. X2.LT.1.0 ) THEN
IF(ABS(X1).GT.1.E-5) THEN
T1LOG=LOG(1.+X1)
ELSE
T1LOG= X1-X1*X1/2.
END IF
IF(ABS(X2).GT.1.E-5) THEN
T2LOG=LOG(1.-X2)
ELSE
T2LOG=-X2-X2*X2/2.
END IF
TT=PVAL(NT+3)*T1LOG+PVAL(NT+4)*T2LOG
TT=MIN(MAX(-80.,TT),+80.)
FNFIT=FNFIT+PVAL(NT)*EXP(TT)
END IF
GOTO 890
C- WIND
550 IF(X.GE.PVAL(NT) .AND. X.LE.PVAL(NT+1)) FNFIT=FNFIT+PVAL(NT+2)
GOTO 890
C- KING
600 IF(PVAL(NT).GT.0.) THEN
TMP=XT(1)/PVAL(NT)
FNFIT=FNFIT+PVAL(NT+2)*(1.+TMP*TMP)**(-PVAL(NT+1))
END IF
GOTO 890
C- LN Natural LOG
620 XC=X-PVAL(NT)
IF(XC.GT.0.) FNFIT=FNFIT+PVAL(NT+1)*LOG(XC)
GOTO 890
C- LORE Lorentz
640 IF(PVAL(NT+1).EQ.0.) GOTO 890
XC=2.*(X-PVAL(NT))/PVAL(NT+1)
DEM=1.+XC*XC
FNFIT=FNFIT+PVAL(NT+2)/DEM
GOTO 890
C- CGaus/NCgaus
650 CONTINUE
xs = (X-PVAL(NT ))/PVAL(NT+2)
ys = (Y-PVAL(NT+1))/PVAL(NT+2)
z2 = xs*xs + ys*ys
ex = 0.
IF ( z2.LT.144.0 ) ex = EXP(-z2/2.)
IF ( IACOMP.EQ.20 ) THEN
C CGaus
FNFIT=FNFIT+PVAL(NT+3)*ex
ELSE
C NCgaus
FNFIT=FNFIT+Pval(Nt+3)*ex/(6.283185307*Pval(Nt+2)*Pval(Nt+2))
END IF
GOTO 890
C- EGaus/NEgaus
660 CONTINUE
ca = COS(Pval(Nt+4)/rtd)
sa = SIN(Pval(Nt+4)/rtd)
xs = ca*(xt(1)-Pval(Nt )) + sa*(xt(2)-Pval(Nt+2))
ys =-sa*(xt(1)-Pval(Nt )) + ca*(xt(2)-Pval(Nt+2))
z2 = (xs/Pval(Nt+1))**2 + (ys/Pval(Nt+3))**2
ex = 0.
IF ( z2.LT.144.0 ) ex = EXP(-z2/2.)
IF ( IACOMP.EQ.22 ) THEN
C Egaus
FNFIT = FNFIT + Pval(nt+5)*ex
ELSE
C NEgaus
FNFIT = FNFIT+Pval(Nt+5)*ex/(6.283185307*Pval(Nt+1)*Pval(Nt+3))
END IF
GOTO 890
C- LY Linear in Y
670 CONTINUE
FNFIT=FNFIT+Pval(Nt)*Y
GOTO 890
C- USER
800 FNFIT=FNFIT+UFNY(XT,PVAL,NT,NTER(IACOMP))
GOTO 890
C- SPLN Spline
820 FNFIT=FNFIT+FNSP(XT,PVAL(NT))
GOTO 890
C- AKIM Akima
860 FNFIT=FNFIT+FNAKIM(XT,PVAL(NT))
GOTO 890
C- COD
880 FNFIT=FNFIT+FNCOD(0,0,XT,PVAL(NT),NTER(IACOMP),IER)
GOTO 890
C---
890 NT=NT+NTER(IACOMP)
IF(NT.LE.NTERM) GOTO 100
RETURN
END
C*********
SUBROUTINE MDERIV(Xt, Icomp, Pval, Plim, Nterm, Deriv)
INTEGER Nterm
REAL Xt(2), Pval(Nterm), Plim(3,*), Deriv(Nterm)
INTEGER Icomp(*)
C---
C Compute the Derivative with respect to the parameter values.
C---
C Xt I The (possibly 2 dimensional) independent variable
C Icomp I
C Pval(*) I
C Plim(3,*) I
C Nterm I
C Deriv(*) O
C---
C AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXCNUM, MXCOD
PARAMETER (MXCNUM=27, MXCOD=1)
C
REAL A2, BT, ca, DEM, EX, FAC, fny0, P1, sa
REAL T, T1, T2, TC, TIM, TMP
REAL TT, T1LOG, T2LOG, X, X1, X2, XC, xs, XLOG, y, ys, z2
INTEGER I, IACOMP, IX, NT
C
REAL XMIN, XMAX
INTEGER ISTAT, NTER
COMMON/FITCMN/XMIN(2),XMAX(2),ISTAT,NTER(MXCNUM+MXCOD)
REAL rtd
DATA rtd/57.2957795/
C---
x = Xt(1)
y = Xt(2)
DO I=1,Nterm
Deriv(I)=0.
END DO
C
NT=1
100 CONTINUE
IACOMP=Icomp(NT)
GOTO (200,210,220,230,240,250,260,300,320,320,360,360,400,450,
: 500,550,600,620,640,650,650,660,660,670,
: 800,820,860,880) IACOMP
C- CONS
200 Deriv(NT)=1.
GOTO 890
C- LINR
210 Deriv(NT)=X
GOTO 890
C- QUAD
220 Deriv(NT)=X*X
GOTO 890
C- CUBI
230 Deriv(NT)=X*X*X
GOTO 890
C- X4
240 Deriv(NT)=X*X*X*X
GOTO 890
C- X5
250 Deriv(NT)=X*X*X*X*X
GOTO 890
C- POWR
260 IF(X.GT.0.) THEN
XLOG=LOG(X)
TMP=Pval(NT)*XLOG
TMP=MIN(MAX(-70.,TMP),70.)
Deriv(NT+1)=EXP(TMP)
Deriv(NT )=Pval(NT+1)*Deriv(NT+1)*XLOG
END IF
GOTO 890
C- SIN
300 IF(Pval(NT).NE.0) THEN
TMP=6.28318531/Pval(NT)
TIM=(X-Pval(NT+1))
Deriv(NT+1)=-Pval(NT+2)*TMP*COS(TMP*TIM)
Deriv(NT )= Deriv(NT+1)*TIM/Pval(NT)
Deriv(NT+2)= SIN(TMP*TIM)
END IF
GOTO 890
C- GAUS/NGAU
320 CONTINUE
xs=(X-Pval(NT))/Pval(NT+1)
EX=0.
IF ( ABS(xs).LT.12.0 ) EX=EXP(-xs*xs/2.)
IF ( IACOMP.EQ.9 ) THEN
C GAus
Deriv(NT )=Pval(NT+2)*EX*xs/Pval(NT+1)
Deriv(NT+1)=xs*Deriv(NT)
Deriv(NT+2)=EX
ELSE
C NGaus
EX = EX/2.50662827
tmp = Pval(NT+2)*EX/(Pval(NT+1)*Pval(NT+1))
Deriv(NT ) = tmp*xs
Deriv(NT+1) = tmp*(xs*xs-1.0)
Deriv(NT+2) = EX/Pval(NT+1)
END IF
GOTO 890
C- EXP and AEXP
360 xs=0.
IF(Pval(NT+1).NE.0.) xs=(X-Pval(NT))/Pval(NT+1)
IF(IACOMP.EQ.12) xs=ABS(xs)
EX=0.
IF(ABS(xs).LT.80.) EX=EXP(-xs)
Deriv(NT)=0.
IF(Pval(NT+1).NE.0.) Deriv(NT)=Pval(NT+2)*EX/Pval(NT+1)
Deriv(NT+1)=xs*Deriv(NT)
Deriv(NT+2)=EX
IF(IACOMP.EQ.12 .AND. X.LT.Pval(NT)) Deriv(NT)=-Deriv(NT)
GOTO 890
C- BURS
400 xs=0.
IF ( X.GT.Pval(NT) ) THEN
IF ( X.LT.Pval(NT+1) ) THEN
DEM=Pval(NT+1)-Pval(NT)
Deriv(NT)=Pval(NT+3)*(X-Pval(NT+1))/(DEM*DEM)
Deriv(NT+1)=-Pval(NT+3)*(X-Pval(NT))/(DEM*DEM)
Deriv(NT+3)=(X-Pval(NT))/DEM
ELSE
IF(Pval(NT+2).NE.0.) xs=(X-Pval(NT+1))/Pval(NT+2)
EX=0.
IF(ABS(xs).LT.80.) EX=EXP(-xs)
Deriv(NT+1)=0.
IF(Pval(NT+2).NE.0.) Deriv(NT+1)=Pval(NT+3)*EX/Pval(NT+2)
Deriv(NT+2)=xs*Deriv(NT+1)
Deriv(NT+3)=EX
END IF
END IF
GOTO 890
C- SBUR
450 T=X-Pval(NT)
IF(T.GT.0) THEN
Pval(NT+2)=ABS(Pval(NT+2))
FAC=1.
IF(Pval(NT+1).NE.0.) FAC=2.718281828/ABS(Pval(NT+1)*Pval(NT+2))
TC=LOG(FAC*T)
P1=Pval(NT+1)*TC-T/Pval(NT+2)
EX=0.
IF(ABS(P1).LT.80.) EX=EXP(P1)
BT=Pval(NT+3)*EX
Deriv(NT )=BT*(1./Pval(NT+2)-Pval(NT+1)/T)
Deriv(NT+1)=BT*(TC-1.)
Deriv(NT+2)=BT*(T-Pval(NT+1)*Pval(NT+2))/
: (Pval(NT+2)*Pval(NT+2))
Deriv(NT+3)= EX
END IF
GOTO 890
C- PEAR
500 A2=Pval(NT+2)*Pval(NT+4)/Pval(NT+3)
X1=(X-Pval(NT+1))/Pval(NT+2)
X2=(X-Pval(NT+1))/A2
IF ( -1.0.LT.X1 .AND. X2.LT.1.0 ) THEN
T1=1.+X1
T2=1.-X2
IF(ABS(X1).GT.1.E-5) THEN
T1LOG=LOG(1.+X1)
ELSE
T1LOG= X1-X1*X1/2.
END IF
IF(ABS(X2).GT.1.E-5) THEN
T2LOG=LOG(1.-X2)
ELSE
T2LOG=-X2-X2*X2/2.
END IF
TT=Pval(NT+3)*T1LOG+Pval(NT+4)*T2LOG
TT=MIN(MAX(-80.,TT),+80.)
Deriv(NT)=EXP(TT)
TMP=Pval(NT)*Deriv(NT)
Deriv(NT+1)=TMP*Pval(NT+3)*(1./T2-1./T1)/Pval(NT+2)
Deriv(NT+2)=X1*Deriv(NT+1)
Deriv(NT+3)=TMP*(T1LOG-X1/T2)
Deriv(NT+4)=TMP*(T2LOG+X2/T2)
END IF
GOTO 890
C- WIND
550 IF(X.GE.Pval(NT) .AND. X.LE.Pval(NT+1)) THEN
Deriv(NT+2)=1.
END IF
GOTO 890
C---
C- KIng
600 IF(Pval(NT).GT.0.) THEN
X1=X/Pval(NT)
TMP=1.+X1*X1
Deriv(NT+2)=TMP**(-Pval(NT+1))
Deriv(NT )=2.*Pval(NT+1)*Pval(NT+2)*Deriv(NT+2)*X1*X1/
: (Pval(NT)*TMP)
Deriv(NT+1)=-Pval(NT+2)*LOG(TMP)*Deriv(NT+2)
END IF
GOTO 890
C- LN Natural LOG
620 XC=X-Pval(NT)
IF(XC.GT.0.) THEN
Deriv(NT+1)=LOG(XC)
Deriv(NT) =-Pval(NT+1)/XC
END IF
GOTO 890
C- LORE Lorentz
640 IF(Pval(NT+1).EQ.0.) GOTO 890
XC=2.*(X-Pval(NT))/Pval(NT+1)
DEM=1.+XC*XC
Deriv(NT )= Pval(NT+2)*4.*XC/(DEM*DEM*Pval(NT+1))
Deriv(NT+1)= Pval(NT+2)*2.*XC*XC/(DEM*DEM*Pval(NT+1))
Deriv(NT+2)=1./DEM
GOTO 890
C- CGaus
650 CONTINUE
xs = (X-Pval(NT ))/Pval(NT+2)
ys = (Y-Pval(NT+1))/Pval(NT+2)
z2 = xs*xs + ys*ys
ex = 0.
IF ( z2.LT.144.0 ) ex = EXP(-z2/2.)
IF ( IACOMP.EQ.20 ) THEN
C CGgaus
Deriv(NT ) = ex*Pval(NT+3)*xs/Pval(NT+2)
Deriv(NT+1) = ex*Pval(NT+3)*ys/Pval(NT+2)
Deriv(NT+2) = ex*Pval(NT+3)*z2/Pval(NT+2)
Deriv(NT+3) = ex
ELSE
C NCgaus
ex = ex/(6.283185307*Pval(NT+2)*Pval(NT+2))
Deriv(NT ) = ex*Pval(NT+3)*xs/Pval(NT+2)
Deriv(NT+1) = ex*Pval(NT+3)*ys/Pval(NT+2)
Deriv(NT+2) = ex*Pval(NT+3)*(z2-2.0)/Pval(NT+2)
Deriv(NT+3) = ex
END IF
GOTO 890
C- EGaus/NEgaus
660 CONTINUE
ca = COS(Pval(nt+4)/rtd)
sa = SIN(Pval(nt+4)/rtd)
xs = ca*(xt(1)-Pval(nt )) + sa*(xt(2)-Pval(nt+2))
ys =-sa*(xt(1)-Pval(nt )) + ca*(xt(2)-Pval(nt+2))
z2 = (xs/Pval(nt+1))**2 + (ys/Pval(nt+3))**2
ex = 0.
IF ( z2.LT.144.0 ) ex = EXP(-z2/2.)
C
IF ( IACOMP.EQ.22 ) THEN
C EGaus
fny0 = ex*Pval(nt+5)
Deriv(nt )=fny0*( xs*ca/Pval(nt+1)**2-ys*sa/Pval(nt+3)**2)
Deriv(nt+1)=fny0*((xs/Pval(nt+1))**2)/Pval(nt+1)
Deriv(nt+2)=fny0*( xs*sa/Pval(nt+1)**2+ys*ca/Pval(nt+3)**2)
Deriv(nt+3)=fny0*((ys/Pval(nt+3))**2)/Pval(nt+3)
Deriv(nt+4)=(fny0/rtd)*(
& ( sa*(xt(1)-Pval(nt))-ca*(xt(2)-Pval(nt+2)) )*xs/Pval(nt+1)**2
& +( ca*(xt(1)-Pval(nt))+sa*(xt(2)-Pval(nt+2)) )*ys/Pval(nt+3)**2)
Deriv(nt+5)=ex
ELSE
C NEgaus
fny0 = ex*Pval(nt+5)/(6.283185307*Pval(nt+1)*Pval(nt+3))
Deriv(nt )=fny0*( xs*ca/Pval(nt+1)**2-ys*sa/Pval(nt+3)**2)
Deriv(nt+1)=fny0*((xs/Pval(nt+1))**2-1)/Pval(nt+1)
Deriv(nt+2)=fny0*( xs*sa/Pval(nt+1)**2+ys*ca/Pval(nt+3)**2)
Deriv(nt+3)=fny0*((ys/Pval(nt+3))**2-1)/Pval(nt+3)
Deriv(nt+4)=(fny0/rtd)*(
& ( sa*(xt(1)-Pval(nt))-ca*(xt(2)-Pval(nt+2)) )*xs/Pval(nt+1)**2
& +( ca*(xt(1)-Pval(nt))+sa*(xt(2)-Pval(nt+2)) )*ys/Pval(nt+3)**2)
Deriv(nt+5)=ex/(6.283185307*Pval(nt+1)*Pval(nt+3))
END IF
GOTO 890
C- LY Linear in Y
670 CONTINUE
Deriv(Nt)=Y
GOTO 890
C- USER model
800 CALL UDeriv(XT,Pval,Plim,Deriv,NT,NTER(IACOMP))
GOTO 890
C- SPLN Spline fit
820 CALL SPDERI(XT,Pval,Plim,Deriv,NT,NTER(IACOMP))
GOTO 890
C- AKIM Akima model.
860 CALL AKDERI(XT,Pval,Plim,Deriv,NT,NTER(IACOMP))
GOTO 890
C- COD
880 CALL CODDER(XT,Pval,Plim,Deriv,NT,NTER(IACOMP))
GOTO 890
C---
890 NT=NT+NTER(IACOMP)
IF(NT.LE.Nterm) GOTO 100
DO I=1,Nterm
C Avoid integer overflows on numbers with BIG sigmas.
IF(Plim(1,I).LT.0.) THEN
IX=NINT(-Plim(1,I))
IF(IX.GT.1) THEN
IF(Plim(2,I).NE.0.) THEN
C Parameter times Plim(2,I)
Deriv(IX)=Deriv(IX)+Plim(2,I)*Deriv(I)
ELSE
C Parameter added to Plim(3,I)
Deriv(IX)=Deriv(IX)+Deriv(I)
END IF
END IF
END IF
END DO
RETURN
END
fv5.5/tcltk/plt/fitit.f 0000644 0002207 0000036 00000004562 13224715127 013736 0 ustar birby lhea SUBROUTINE FITIT(Y, Lery, Mxrow, Igroup,
: Iyoff0, Npts, Xmin, Xmax, Isgood, Iegood,
: Niter, Istat, Icomp, Par, Plim, Nterm, Chi)
REAL Y(*), Xmin(*), Xmax(*), Par(*), Plim(3,*), Chi
INTEGER Lery, Mxrow, Igroup
INTEGER Iyoff0, Npts, Isgood, Iegood
INTEGER Niter, Icomp(*), Nterm, Istat
C---
C Calculate the number of points in the range, set Isgood and Iegood
C to be first and last points in the range. Report number of points
C to user and then call CURFIT.
C---
C Y
C Lery
C Mxrow
C Igroup
C Iyoff0
C Npts
C Xmin I The smallest X to include in fit.
C Xmax I The largest X to include in fit.
C Isgood O The smallest index included in fit.
C Iegood O The largest index included in fit.
C Niter
C Istat
C Icomp
C Par
C Plim
C Nterm
C Chi
C---
C 1990-Mar-06 - Extracted from FIT [AFT]
C---
INTEGER MXDIM
PARAMETER (MXDIM=2)
REAL NO
PARAMETER (NO=-1.2E-34)
REAL WEIGHT
C
REAL xt(MXDIM)
REAL wtmp
INTEGER iyoff
INTEGER I, iyi, K, ndim, nfit, nidim
C---
C The following code finds the first and last points in the range that
C are to be included in the fit. This greatly speeds up the fitting
C of short segments of data.
nfit=0
Isgood=0
Iegood=0
CALL PLTXCC(Y, 1, igroup, xt, nidim, iyoff)
DO 190 I=1,Npts
CALL PLTXCC(Y, i, igroup, xt, ndim, iyoff)
IF ( xt(1).EQ.NO ) GOTO 190
IF ( xt(1).LT.Xmin(1) .OR. xt(1).GT.Xmax(1) ) GOTO 190
IF ( nidim.GT.1 ) THEN
IF ( xt(2).LT.Xmin(2) .OR. xt(2).GT.Xmax(2) ) GOTO 190
END IF
iyi = iyoff0 + iyoff
wtmp = WEIGHT(Y(iyi), Mxrow, Lery)
IF ( wtmp.LE.0. ) GOTO 190
nfit=nfit+1
IF ( Isgood.EQ.0 ) Isgood=I
Iegood=I
190 CONTINUE
IF(nfit.LE.0) THEN
WRITE(*,231)
231 FORMAT('FITIT--No points in allowed range.')
RETURN
END IF
WRITE(*,251) nfit,Iegood-Isgood+1
251 FORMAT(' Fitting',I8,' points in a band of',I8,'.')
Par(Nterm+2)=nfit
WRITE(*,*) (Par(K),K=1,Nterm)
C---
C Blast off
CALL CURFIT(Y, Igroup, Iyoff0, Lery, Mxrow, Isgood, Iegood,
: Xmin, Xmax, 1, Niter, Istat, Icomp, 1, Nterm,
& 0.0, Par, Plim, Chi)
C---
Par(Nterm+1)=Chi
WRITE(*,*) (Par(K),K=1,Nterm)
RETURN
END
fv5.5/tcltk/plt/gamma.f 0000644 0002207 0000036 00000023040 13224715127 013671 0 ustar birby lhea C From Netlib http://www.netlib.org/specfun/index.html
REAL FUNCTION GAMMA(X)
C----------------------------------------------------------------------
C
C This routine calculates the GAMMA function for a real argument X.
C Computation is based on an algorithm outlined in reference 1.
C The program uses rational functions that approximate the GAMMA
C function to at least 20 significant decimal digits. Coefficients
C for the approximation over the interval (1,2) are unpublished.
C Those for the approximation for X .GE. 12 are from reference 2.
C The accuracy achieved depends on the arithmetic system, the
C compiler, the intrinsic functions, and proper selection of the
C machine-dependent constants.
C
C
C*******************************************************************
C*******************************************************************
C
C Explanation of machine-dependent constants
C
C beta - radix for the floating-point representation
C maxexp - the smallest positive power of beta that overflows
C XBIG - the largest argument for which GAMMA(X) is representable
C in the machine, i.e., the solution to the equation
C GAMMA(XBIG) = beta**maxexp
C XINF - the largest machine representable floating-point number;
C approximately beta**maxexp
C EPS - the smallest positive floating-point number such that
C 1.0+EPS .GT. 1.0
C XMININ - the smallest positive floating-point number such that
C 1/XMININ is machine representable
C
C Approximate values for some important machines are:
C
C beta maxexp XBIG
C
C CRAY-1 (S.P.) 2 8191 966.961
C Cyber 180/855
C under NOS (S.P.) 2 1070 177.803
C IEEE (IBM/XT,
C SUN, etc.) (S.P.) 2 128 35.040
C IEEE (IBM/XT,
C SUN, etc.) (D.P.) 2 1024 171.624
C IBM 3033 (D.P.) 16 63 57.574
C VAX D-Format (D.P.) 2 127 34.844
C VAX G-Format (D.P.) 2 1023 171.489
C
C XINF EPS XMININ
C
C CRAY-1 (S.P.) 5.45E+2465 7.11E-15 1.84E-2466
C Cyber 180/855
C under NOS (S.P.) 1.26E+322 3.55E-15 3.14E-294
C IEEE (IBM/XT,
C SUN, etc.) (S.P.) 3.40E+38 1.19E-7 1.18E-38
C IEEE (IBM/XT,
C SUN, etc.) (D.P.) 1.79D+308 2.22D-16 2.23D-308
C IBM 3033 (D.P.) 7.23D+75 2.22D-16 1.39D-76
C VAX D-Format (D.P.) 1.70D+38 1.39D-17 5.88D-39
C VAX G-Format (D.P.) 8.98D+307 1.11D-16 1.12D-308
C
C*******************************************************************
C*******************************************************************
C
C Error returns
C
C The program returns the value XINF for singularities or
C when overflow would occur. The computation is believed
C to be free of underflow and overflow.
C
C
C Intrinsic functions required are:
C
C INT, DBLE, EXP, LOG, REAL, SIN
C
C
C References: "An Overview of Software Development for Special
C Functions", W. J. Cody, Lecture Notes in Mathematics,
C 506, Numerical Analysis Dundee, 1975, G. A. Watson
C (ed.), Springer Verlag, Berlin, 1976.
C
C Computer Approximations, Hart, Et. Al., Wiley and
C sons, New York, 1968.
C
C Latest modification: October 12, 1989
C
C Authors: W. J. Cody and L. Stoltz
C Applied Mathematics Division
C Argonne National Laboratory
C Argonne, IL 60439
C
C----------------------------------------------------------------------
INTEGER I,N
LOGICAL PARITY
REAL
1 C,CONV,EPS,FACT,HALF,ONE,P,PI,Q,RES,SQRTPI,SUM,TWELVE,
2 TWO,X,XBIG,XDEN,XINF,XMININ,XNUM,Y,Y1,YSQ,Z,ZERO
DIMENSION C(7),P(8),Q(8)
C----------------------------------------------------------------------
C Mathematical constants
C----------------------------------------------------------------------
DATA ONE,HALF,TWELVE,TWO,ZERO/1.0E0,0.5E0,12.0E0,2.0E0,0.0E0/,
1 SQRTPI/0.9189385332046727417803297E0/,
2 PI/3.1415926535897932384626434E0/
C----------------------------------------------------------------------
C Machine dependent parameters
C----------------------------------------------------------------------
DATA XBIG,XMININ,EPS/35.040E0,1.18E-38,1.19E-7/,
1 XINF/3.4E38/
C----------------------------------------------------------------------
C Numerator and denominator coefficients for rational minimax
C approximation over (1,2).
C----------------------------------------------------------------------
DATA P/-1.71618513886549492533811E+0,2.47656508055759199108314E+1,
1 -3.79804256470945635097577E+2,6.29331155312818442661052E+2,
2 8.66966202790413211295064E+2,-3.14512729688483675254357E+4,
3 -3.61444134186911729807069E+4,6.64561438202405440627855E+4/
DATA Q/-3.08402300119738975254353E+1,3.15350626979604161529144E+2,
1 -1.01515636749021914166146E+3,-3.10777167157231109440444E+3,
2 2.25381184209801510330112E+4,4.75584627752788110767815E+3,
3 -1.34659959864969306392456E+5,-1.15132259675553483497211E+5/
C----------------------------------------------------------------------
C Coefficients for minimax approximation over (12, INF).
C----------------------------------------------------------------------
DATA C/-1.910444077728E-03,8.4171387781295E-04,
1 -5.952379913043012E-04,7.93650793500350248E-04,
2 -2.777777777777681622553E-03,8.333333333333333331554247E-02,
3 5.7083835261E-03/
C----------------------------------------------------------------------
C Statement functions for conversion between integer and float
C----------------------------------------------------------------------
CONV(I) = REAL(I)
PARITY = .FALSE.
FACT = ONE
N = 0
Y = X
IF (Y .LE. ZERO) THEN
C----------------------------------------------------------------------
C Argument is negative
C----------------------------------------------------------------------
Y = -X
Y1 = AINT(Y)
RES = Y - Y1
IF (RES .NE. ZERO) THEN
IF (Y1 .NE. AINT(Y1*HALF)*TWO) PARITY = .TRUE.
FACT = -PI / SIN(PI*RES)
Y = Y + ONE
ELSE
RES = XINF
GO TO 900
END IF
END IF
C----------------------------------------------------------------------
C Argument is positive
C----------------------------------------------------------------------
IF (Y .LT. EPS) THEN
C----------------------------------------------------------------------
C Argument .LT. EPS
C----------------------------------------------------------------------
IF (Y .GE. XMININ) THEN
RES = ONE / Y
ELSE
RES = XINF
GO TO 900
END IF
ELSE IF (Y .LT. TWELVE) THEN
Y1 = Y
IF (Y .LT. ONE) THEN
C----------------------------------------------------------------------
C 0.0 .LT. argument .LT. 1.0
C----------------------------------------------------------------------
Z = Y
Y = Y + ONE
ELSE
C----------------------------------------------------------------------
C 1.0 .LT. argument .LT. 12.0, reduce argument if necessary
C----------------------------------------------------------------------
N = INT(Y) - 1
Y = Y - CONV(N)
Z = Y - ONE
END IF
C----------------------------------------------------------------------
C Evaluate approximation for 1.0 .LT. argument .LT. 2.0
C----------------------------------------------------------------------
XNUM = ZERO
XDEN = ONE
DO 260 I = 1, 8
XNUM = (XNUM + P(I)) * Z
XDEN = XDEN * Z + Q(I)
260 CONTINUE
RES = XNUM / XDEN + ONE
IF (Y1 .LT. Y) THEN
C----------------------------------------------------------------------
C Adjust result for case 0.0 .LT. argument .LT. 1.0
C----------------------------------------------------------------------
RES = RES / Y1
ELSE IF (Y1 .GT. Y) THEN
C----------------------------------------------------------------------
C Adjust result for case 2.0 .LT. argument .LT. 12.0
C----------------------------------------------------------------------
DO 290 I = 1, N
RES = RES * Y
Y = Y + ONE
290 CONTINUE
END IF
ELSE
C----------------------------------------------------------------------
C Evaluate for argument .GE. 12.0,
C----------------------------------------------------------------------
IF (Y .LE. XBIG) THEN
YSQ = Y * Y
SUM = C(7)
DO 350 I = 1, 6
SUM = SUM / YSQ + C(I)
350 CONTINUE
SUM = SUM/Y - Y + SQRTPI
SUM = SUM + (Y-HALF)*LOG(Y)
RES = EXP(SUM)
ELSE
RES = XINF
GO TO 900
END IF
END IF
C----------------------------------------------------------------------
C Final adjustments and return
C----------------------------------------------------------------------
IF (PARITY) RES = -RES
IF (FACT .NE. ONE) RES = FACT / RES
900 GAMMA = RES
RETURN
C ---------- Last line of GAMMA ----------
END
fv5.5/tcltk/plt/gthelp.f 0000644 0002207 0000036 00000001654 13224715127 014101 0 ustar birby lhea SUBROUTINE GTHELP(Clib, Ctopic)
CHARACTER Clib*(*), Ctopic*(*)
C---
C Display the help text from the Clib help library on topic Ctopic.
C---
C Clib I Location of help libary.
C Ctopic I The topic of interest.
C---
C 2002-May-24 - New routine [AFT]
C----
INTEGER LENACT
C
INTEGER ier, itmp, llib
C
CHARACTER chelp*256
SAVE chelp
INTEGER ifirst, lhelp
SAVE ifirst, lhelp
DATA ifirst/1/, lhelp/0/
C
IF ( ifirst.NE.0 ) THEN
CALL TRLOG('XANHTML',7,chelp,lhelp)
IF ( lhelp.LE.0 ) THEN
CALL PTBUF('Problem with setup, Variable XANHTML is not '//
& 'defined.',0)
RETURN
END IF
END IF
llib = LENACT(Clib)
chelp(lhelp+1:) = ' '//Clib(:llib)//'/index.html &'
itmp = LENACT(chelp)
WRITE(*,*) 'chelp=',chelp(:itmp)
CALL SPAWN(chelp, itmp, ier)
RETURN
END
fv5.5/tcltk/plt/hdecod.f 0000644 0002207 0000036 00000002246 13224715127 014042 0 ustar birby lhea SUBROUTINE hdecod(Cbuf, Lbuf)
CHARACTER Cbuf*(*)
INTEGER Lbuf
C---
C Web browsers encode data sending back to the server. This routine
C effectively decodes by converting
C
C 1) "+" symbols back to spaces,
C 2) and hex codes (%xx) back to the original characters.
C---
C Cbuf I/O Buffer
C Lbuf I/O Active length
C---
C 1999-Apr-20 - [AFT]
C---
INTEGER i, ihex, itmp, lout
C---
lout = 0
i = 1
110 CONTINUE
IF ( Cbuf(i:i).EQ.'+' ) THEN
C Turn + signs into spaces
lout = lout + 1
Cbuf(lout:lout) = ' '
ELSE IF ( Cbuf(i:i).EQ.'%' ) THEN
C Decode the HEX strings
i = i + 1
ihex = ICHAR(Cbuf(i:i)) - ICHAR('0')
IF ( ihex.GT.9 ) ihex = ihex - 7
i = i + 1
itmp = ICHAR(Cbuf(i:i)) - ICHAR('0')
IF ( itmp.GT.9 ) itmp = itmp - 7
lout = lout + 1
Cbuf(lout:lout) = CHAR(ihex*16+itmp)
ELSE
C Just copy the original character
lout = lout + 1
Cbuf(lout:lout) = Cbuf(i:i)
END IF
i = i + 1
IF ( i.LE.Lbuf ) GOTO 110
C---
Lbuf = lout
RETURN
END
fv5.5/tcltk/plt/ifgrp.f 0000644 0002207 0000036 00000000554 13224715127 013723 0 ustar birby lhea INTEGER FUNCTION IFGRP(IWIN, MXGRP, IWNUM)
INTEGER IWIN(*), MXGRP, IWNUM
C---
C Find the first group to be plotted in the current window
C---
INTEGER IGROUP
C---
DO 190 IGROUP=1,MXGRP
IF(IWIN(IGROUP).EQ.IWNUM) THEN
IFGRP=IGROUP
RETURN
END IF
190 CONTINUE
IFGRP=0
RETURN
END
fv5.5/tcltk/plt/isact.f 0000644 0002207 0000036 00000001250 13224715127 013711 0 ustar birby lhea INTEGER FUNCTION ISACT(IWIN, NGROUP, ICONT, ICWIN)
INTEGER IWIN(*), NGROUP, ICONT, ICWIN
C---
C Runs throught the IWIN array and returns 1 if ICWIN is currently
C active, and 0 otherwise
C---
C IWIN I Contains window that each group is to be plotted in
C NGROUP I The number of groups
C ICWIN I The current window
C---
C 1990-Jun-12
C---
INTEGER I
C---
C Activate windows that contain data
DO 150 I=1,NGROUP
IF(IWIN(I).EQ.ICWIN) THEN
ISACT=1
RETURN
END IF
150 CONTINUE
IF(ICONT.NE.0 .AND. ICWIN.EQ.1) THEN
ISACT=1
ELSE
ISACT=0
END IF
RETURN
END
fv5.5/tcltk/plt/moment.f 0000644 0002207 0000036 00000012772 13224715127 014120 0 ustar birby lhea SUBROUTINE MOMENT(Iprnt, Y, Iery, Mxrow, Igroup, Iy0,
: Npts, Pmin, Pmax, Tot, Ier)
INTEGER Iprnt, Iery, Mxrow, Igroup, Iy0, Npts, Ier
REAL Pmin(*), Pmax(*), Y(*), Tot(14)
C---
C Computes moments of array Y. Makes two passes through the data
C to generate accurate results.
C---
C Tot( 1) O Sum of 1 =Npts
C Tot( 2) O Average Y =YBAR
C Tot( 3) O Sum of (Y-YBAR)**2 =(Npts-1)*VAR(Y)
C Tot( 4) O Sum of (Y-YBAR)**3 =(Npts-1)*SKEW(Y)
C Tot( 5) O Average X =XBAR
C Tot( 6) O Sum of (X-XBAR)**2 =(Npts-1)*VAR(X)
C Tot( 7) O Sum of (X-XBAR)*(Y-YBAR)
C Tot( 8.. 9) O YMIN, YMAX
C Tot(10..13) O Sum of W, W*Y, W*Y*Y, W*Y*Y*Y
C Tot(14) O Sum of Y*XDEL (i.e., the integral)
C---
INTEGER MXDIM
PARAMETER (MXDIM=2)
REAL NO
PARAMETER (NO=-1.2E-34)
REAL WEIGHT
C---
CHARACTER cbuf*80
DOUBLE PRECISION dyint, sumx, sumx2, sumxy
DOUBLE PRECISION sumwy, sumwy2, sumwy3, sumw
DOUBLE PRECISION sumy, sumy2, sumy3
DOUBLE PRECISION dxbar, dybar, dwybar
REAL ym(6), xc(MXDIM)
REAL FRAC, xdel, TMP, XT, xm, ydel, YMAX, YMIN, xp
REAL YT, y2, y3, W
INTEGER I, ipxer, itmp, iyi, iyoff, K, N, ndim
C---
C
C Query the X error plotting status
CALL PLTXCQ(Igroup, 1, ipxer)
C We use the X error to integrate, so make sure it will be returned.
CALL PLTXCP(Igroup, 1, 1)
DO I=1,6
ym(I)=0.
END DO
N=0
sumy =0.
sumx =0.
YMIN= 1.E37
YMAX=-1.E37
sumw =0.
sumwy =0.
dyint =0.
CALL PLTXCC(Y, 1, Igroup, xc, ndim, iyoff)
IF ( ndim.LE.1 ) THEN
ydel = 1.0
ELSE
C First we check the y-delta which is only used if we have a 2D group.
CALL PLTXCQ(Igroup, 2, itmp)
CALL PLTXCP(Igroup, 2, 1)
CALL PLTXCE(Y, 1, Igroup, 2, xm, xp)
ydel = xp - xm
CALL PLTXCP(Igroup, 2, itmp)
END IF
DO 150 I=1, Npts
CALL PLTXCC(Y, i, igroup, xc, ndim, iyoff)
IF ( xc(1).EQ.NO ) GOTO 150
iyi = Iy0 + iyoff
IF ( xc(1).LT.Pmin(1) .OR. xc(1).GT.Pmax(1) ) GOTO 150
C If ndim.LE.1 then xc(2), pmin(2), pmax(2) are all undefined, so
C make sure they are not evaluted.
IF ( ndim.GT.1 ) THEN
IF ( xc(2).LT.Pmin(2) .OR. xc(2).GT.Pmax(2) ) GOTO 150
END IF
W=WEIGHT(Y(iyi),Mxrow,Iery)
IF(W.GT.0.) THEN
N =N+1
sumy =sumy+Y(iyi)
sumx =sumx+xc(1)
YMIN =MIN(YMIN,Y(iyi))
YMAX =MAX(YMAX,Y(iyi))
sumw =sumw +W
sumwy=sumwy+W*Y(iyi)
CALL PLTXCE(Y, i, igroup, 1, xm, xp)
xdel = xp - xm
dyint=dyint+Y(iyi)*XDEL*ydel
END IF
150 CONTINUE
IF ( N.LE.0 ) THEN
CALL PTBUF('ERROR--MOMENT no data.',-1)
Ier=2
RETURN
END IF
dybar =sumy/N
dxbar =sumx/N
dwybar=sumwy/sumw
C---
sumy2=0.
sumy3=0.
sumx2=0.
sumxy=0.
sumwy2=0.
sumwy3=0.
DO 190 I=1,Npts
CALL PLTXCC(Y, i, igroup, xc, ndim, iyoff)
IF ( xc(1).EQ.NO ) GOTO 190
iyi = iy0 + iyoff
IF ( xc(1).LT.Pmin(1) .OR. xc(1).GT.Pmax(1) ) GOTO 190
IF ( ndim.GT.1 ) THEN
IF ( xc(2).LT.Pmin(2) .OR. xc(2).GT.Pmax(2) ) GOTO 190
END IF
W=WEIGHT(Y(iyi),Mxrow,Iery)
IF ( W.GT.0. ) THEN
XT=xc(1)-dxbar
YT=Y(iyi)-dybar
Y2=YT*YT
Y3=Y2*YT
sumy2 =sumy2 +Y2
sumy3 =sumy3 +Y3
sumx2 =sumx2 +XT*XT
sumxy =sumxy +XT*YT
YT=Y(iyi)-dwybar
Y2=YT*YT
Y3=Y2*YT
sumwy2=sumwy2+W*Y2
sumwy3=sumwy3+W*Y3
END IF
190 CONTINUE
Tot( 1) = N
Tot( 2) = dybar
Tot( 3) = sumy2
Tot( 4) = sumy3
Tot( 5) = dxbar
Tot( 6) = sumx2
Tot( 7) = sumxy
Tot( 8) = YMIN
Tot( 9) = YMAX
Tot(10) = sumw
Tot(11) = dwybar
Tot(12) = sumwy2
Tot(13) = sumwy3
Tot(14) = dyint
IF(N.LE.1) THEN
CALL PTBUF('MOMENT--Not enough data.',-1)
Ier=1
RETURN
END IF
dybar=sumy/N
FRAC=N/(N-1.)
ym(1)=Tot(2)
ym(2)=Tot(3)/(N-1.)
ym(3)=Tot(4)/(N-1.)
dwybar=sumwy/sumw
ym(4)=Tot(11)
ym(5)=FRAC*Tot(12)/sumw
ym(6)=FRAC*Tot(13)/sumw
IF(Iprnt.NE.0) THEN
WRITE(cbuf,351)
351 FORMAT(' \ YBAR',8X,'YVAR',8X,'Y3M',9X,'SUMW',8X,
& 'YMIN',8X,'YMAX')
CALL PTBUF(cbuf, -1)
WRITE(cbuf,361) 'UNWTD',(ym(K),K=1,3),FLOAT(N),YMIN,YMAX
361 FORMAT(A6,1P,4G12.4,2G12.4)
CALL PTBUF(cbuf, -1)
IF(Iery.NE.0) THEN
C If we have errors, print out the weighted values, plus CHI^2 which
C is effectively the weighted variance.
WRITE(cbuf,361) ' WTD',(ym(K),K=4,6),sumw
CALL PTBUF(cbuf, -1)
IF(N.GT.1) THEN
TMP=Tot(12)/(N-1.)
IF(TMP.LT.9999.9) THEN
WRITE(cbuf,381) Tot(12),TMP
381 FORMAT(' WCHI=',1PG11.3,', WRED=',0PF9.3)
CALL PTBUF(cbuf, -1)
ELSE
WRITE(cbuf,391) Tot(12),TMP
391 FORMAT(' WCHI=',1PG11.3,', WRED=',G11.3)
CALL PTBUF(cbuf, -1)
END IF
END IF
END IF
END IF
CALL PLTXCP(Igroup, 1, ipxer)
RETURN
END
fv5.5/tcltk/plt/pgdev.f 0000644 0002207 0000036 00000002212 13224715127 013712 0 ustar birby lhea c
c pgdev -- set output device
c
subroutine pgdev(file)
implicit none
character*(*) file
integer LR,LDEV,LF
integer ier
character*256 req,device
integer lenact
call pgqinf ('DEVICE',device,ldev)
if ( device(1:1).eq.'?' ) then
device = ' '
ldev = 0
endif
if (file(1:1) .eq. '?') then
if (ldev .le. 0) then
call pgldev
10 call xcread('Graphics device/type (? to see list): ', req,
& ier)
lr = LENACT(req)
if (ier .ne. 0)
& call xwrite(' error reading device specification',5)
if (lr .lt. 1) goto 10
if (req(1:1) .eq. '?') then
call pgldev
goto 10
end if
call setenv (req)
end if
else if (file(1:1) .eq. '!') then
call pgldev
else
lf=index(file,' ')-1
if (lf .eq. -1) lf=lenact(file)
call setenv(file)
end if
return
end
fv5.5/tcltk/plt/pgplot.f 0000644 0002207 0000036 00000027317 13224715127 014127 0 ustar birby lhea C- PGPLOT. Contains device dependent routines.
C- This version drives PGPLOT routines.
C*********
SUBROUTINE PLTCLR
C---
C Clear workstation.
C---
CALL PGADVANCE
RETURN
END
C*********
SUBROUTINE PLTCS(SCHAR)
REAL SCHAR
C---
C Set character size. Default size is 1.0.
C---
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
C---
CALL PGSCH(SCHAR)
SIZCHR=SCHAR
RETURN
END
C**********
SUBROUTINE PLTFON(CBUF)
CHARACTER CBUF*(*)
C---
C Set default font. If CBUF(1:1) is not a legal font character,
C then display possible fonts on terminal.
C---
CALL UPC(CBUF(1:1))
IF(CBUF(1:1).EQ.'N') THEN
CALL PGSCF(1)
ELSE IF(CBUF(1:1).EQ.'R') THEN
CALL PGSCF(2)
ELSE IF(CBUF(1:1).EQ.'I') THEN
CALL PGSCF(3)
ELSE IF(CBUF(1:1).EQ.'S') THEN
CALL PGSCF(4)
ELSE
WRITE(*,101)
101 FORMAT(' Legal fonts are: Normal, Roman, Italic, Script')
RETURN
END IF
RETURN
END
C**********
SUBROUTINE PLTHAR(CDEV)
CHARACTER CDEV*(*)
C---
C Returns the name of a hardcopy device
C---
INTEGER LDEV
C---
CALL TRLOG('PLT_HARDCOPY',12,CDEV,LDEV)
IF(LDEV.EQ.0) CDEV='/PS'
RETURN
END
C*********
SUBROUTINE PLTMAR
C---
C Based on PGEX8. Show the user the standard PGPLOT marker types.
C---
CHARACTER LABEL*2
REAL xzero(1), yzero(1)
REAL X, X1, X2, XOFF, Y, Y1, Y2, YOFF, DX, DY
INTEGER NX, NY, N, IX, JY, icisav
DATA xzero,yzero/0.0,0.0/
C---
CALL PGQCI(icisav)
CALL PGVPORT(0.0, 1.0, 0.0, 1.0)
CALL PGQVP(1, X1, X2, Y1, Y2)
X = X2-X1
Y = Y2-Y1
C
NX = 8
NY = 4
DX = MIN(X/NX, 0.95*Y/NY)
DY = DX
IX = NX
JY = 1
XOFF = X1 + (X-NX*DX)*0.5
YOFF = Y1 + (0.95*Y-NY*DY)*0.5
CALL PGBBUF
CALL PGSCI(1)
C
C Each symbol will be drawn in a standard window; the window is moved
C by manipulating the viewport.
C
CALL PGWINDOW(-1.,1.,-1.,1.)
C
C Loop through all known symbols (N=0-31).
C
DO N=0,31
WRITE (LABEL,'(I2)') N
C
C Define window and viewport. The loop allows the plot to extend over
C more than one page if necessary; each page is labelled at the top.
C
IX = IX+1
IF (IX.GT.NX) THEN
IX = 1
JY = JY-1
END IF
IF (JY.LT.1) THEN
JY = NY
CALL PLTCLR
CALL PGSCH(1.2)
CALL PGVSIZE(XOFF, XOFF+NX*DX, YOFF, YOFF+NY*DY)
CALL PGMTEXT('T', 1.0, 0.5, 0.5, 'PGPLOT Marker Symbols')
END IF
CALL PGVSIZE(XOFF+(IX-1)*DX, XOFF+IX*DX,
1 YOFF+(JY-1)*DY, YOFF+JY*DY)
C
C Call PGBOX to draw a box and PGMTEXT to label it.
C
CALL PGBOX('BC',10.0,0,'BC',10.0,0)
CALL PGSCH(1.0)
CALL PGMTEXT('T',-1.5,0.05,0.0,LABEL)
C
C Call PGPOINT to draw the symbol.
C
CALL PGSCH(1.5)
C NAG compiler likes args 2 and 3 to be consistent, i.e., an array.
CALL PGPOINT(1,xzero,yzero,N)
END DO
C
CALL PGEBUF
CALL PGSCI(icisav)
RETURN
END
C*********
SUBROUTINE PLTOPE(Cdev, Ibcol, Scrcol, Cfont, Pgpapw, Pgpapa, Ier)
CHARACTER Cdev*(*), Cfont*(*)
INTEGER Ibcol, Ier
REAL Scrcol(3,0:15), Pgpapw, Pgpapa
C---
C Open workstation.
C---
C Cdev I
C Ibcol I
C Scrcol I
C Cfont I
C Pgpapw I
C Pgpapa I
C Ier O
C---
REAL NO
PARAMETER (NO = -1.2E-34)
INTEGER PGBEG
C
INTEGER i
C---
IF(PGBEG(0,Cdev,1,1).NE.1) GOTO 900
CALL PGASK(.FALSE.)
IF(CFONT.NE.' ') CALL PLTFON(CFONT)
IF ( PGPAPW.GT.0.0 ) THEN
CALL PGPAP(Pgpapw/2.54,Pgpapa)
END IF
CALL PLTOP1(ibcol)
DO i=0,15
IF ( Scrcol(1,i).NE.NO ) THEN
CALL PGSCR(i,Scrcol(1,i),Scrcol(2,i),Scrcol(3,i))
END IF
END DO
Ier = 0
RETURN
C---
900 IER=1
RETURN
END
C*********
SUBROUTINE PLTOP1(ibcol)
INTEGER ibcol
C---
C This routine should only be called if plot device is open.
C Allows user to specify black or white to be the default background color.
C---
C ibcol I =0 ignore, <0 black background, >0 white background
C---
IF ( ibcol.LT.0 ) THEN
C Force black background
CALL PGSCR(0,0.0,0.0,0.0)
CALL PGSCR(1,1.0,1.0,1.0)
CALL PGUPDT
ELSE IF ( ibcol.GT.0 ) THEN
C Force white background
CALL PGSCR(0,1.0,1.0,1.0)
CALL PGSCR(1,0.0,0.0,0.0)
CALL PGUPDT
END IF
RETURN
END
C*********
SUBROUTINE PLTPM(NUM, XRAY, YRAY)
INTEGER NUM
REAL XRAY(1),YRAY(1)
C---
C Plot Polymarker.
C---
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
C---
CALL PGPOINT(NUM,XRAY,YRAY,MARK)
RETURN
END
C*********
SUBROUTINE PLTPRO(CPFILE, IER)
CHARACTER CPFILE*(*)
INTEGER IER, LPFILE
C---
C Prompt for PGPLOT device name.
C---
100 CALL GTBUF('PGPLOT file/type:',IER)
IF(IER.LT.0) GOTO 900
CALL GTREST(CPFILE, LPFILE)
IF(CPFILE(1:1).EQ.'?') THEN
CALL PGLDEV
GOTO 100
END IF
IER=0
RETURN
C---
900 IER=-1
RETURN
END
C*********
SUBROUTINE PLTSCI(ICOL)
INTEGER ICOL
C---
C Set color index. 0=background, 1=foreground
C---
IF(ICOL.LT.0) THEN
WRITE(*,101)
101 FORMAT(' PGPLOT colors are:'/
: ' 0=Backg, 1=Foreg, 2=Red, 3=Green,'/
: ' 4=Blue, 5=Light blue, 6=Magenta, 7=Yellow,'/
: ' 8=Orange, 9=Yel.+Green, 10=Green+Cyan, 11=Blue+Cyan,'/
: ' 12=Blue+Mag, 13=Red+Mag, 14=Dark Grey, 15=Light Grey')
RETURN
ELSE
CALL PGSCI(ICOL)
END IF
RETURN
END
C*********
SUBROUTINE PLTSLS(LS)
INTEGER LS
C---
C Set line style.
C---
INTEGER ITMP
C---
IF(LS.LT.0) THEN
WRITE(*,101)
101 FORMAT(' PGPLOT line styles are:'/
: ' 1=Solid, 2=Dash, 3=Dash-dot, 4=Dot, 5=Dash-dot-dot-dot')
ELSE
ITMP=MOD(LS-1,5)+1
CALL PGSLS(ITMP)
END IF
RETURN
END
C*********
SUBROUTINE PLTSLW(WIDTH)
REAL WIDTH
C---
C Set line width.
C---
CALL PGSLW(NINT(WIDTH))
RETURN
END
C*********
SUBROUTINE PLTSMK(IMARK)
INTEGER IMARK
C---
C Set marker type.
C---
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
C---
MARK=IMARK
RETURN
END
C*********
SUBROUTINE PLTTEX(X1, Y1, ANGLE, IJUS, LOC, CTEXT)
REAL X1, Y1, ANGLE
INTEGER IJUS, LOC
CHARACTER CTEXT*(*)
C---
C X1, Y1 I Location of text in window coordinates
C ANGLE I Angle of text in degrees from X-axis
C IJUS I =1 X1,Y1 is left of string
C =2 X1,Y1 is in center of string
C =3 X1,Y1 is right of string
C LOC I =1 X1,Y1 is at Top of text.
C =2 X1,Y1 is at Cap of text.
C =3 X1,Y1 is at Half of text.
C =4 X1,Y1 is at Base of text.
C =5 X1,Y1 is at Bottom of text.
C CTEXT I The text string
C---
REAL FJUST(3), VOFF(5), YC
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
DATA FJUST/0.0,0.5,1.0/
DATA VOFF/-0.020,-0.012,-0.008,0,+.006/
C---
YC=Y1+VOFF(LOC)*SIZCHR*(WYMAX-WYMIN)/(VYMAX-VYMIN)
CALL PGPTEXT(X1,YC,ANGLE,FJUST(IJUS),CTEXT)
RETURN
END
C*********
SUBROUTINE PLTVTW(VX, VY, WX, WY)
REAL VX, VY, WX, WY
C---
C Convert viewport coordinates to window coordinates
C---
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
C---
WX=WXMIN+(VX-VXMIN)*(WXMAX-WXMIN)/(VXMAX-VXMIN)
WY=WYMIN+(VY-VYMIN)*(WYMAX-WYMIN)/(VYMAX-VYMIN)
RETURN
END
C*********
SUBROUTINE PLTWTV(WX, WY, VX, VY)
REAL WX, WY, VX, VY
C---
C Convert window coordinates to viewport coordinates
C---
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
C---
VX=VXMIN+(WX-WXMIN)*(VXMAX-VXMIN)/(WXMAX-WXMIN)
VY=VYMIN+(WY-WYMIN)*(VYMAX-VYMIN)/(WYMAX-WYMIN)
RETURN
END
C*********
SUBROUTINE PLTSVW(BOXVP, WINLOC, XYSCAL, LOGX, LOGY, IADJ, IWNUM)
REAL BOXVP(4,*), WINLOC(4,*), XYSCAL(4,*)
INTEGER IWNUM, LOGX(*), LOGY(*), IADJ(*)
C---
C Set both viewport and window scale for the current window number. If
C a window adjustment occurs, then on return BOXVP reflects the new value.
C If IWNUM=0 then the full screen is used and window adjustment is ignored.
C---
C BOXVP I/O Size of box in viewport coordinates
C WINLOC I Location of selected window in device independent coordinates
C XYSCAL I World coordinates for box
C LOGX I <>0 for Log scale on X-axis
C LOGY I <>0 for Log scale on Y-axis
C IADJ I <>0 to call PGWNAD
C IWNUM I Window number
C---
C- The minimum number that can be LOG'ed.
REAL RMNLOG
PARAMETER (RMNLOG=1.E-36)
C
REAL TMP
C
REAL VXMIN,VXMAX,VYMIN,VYMAX
REAL WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR
INTEGER MARK
COMMON /PLTCMN/ VXMIN,VXMAX,VYMIN,VYMAX,
: WXMIN,WXMAX,WYMIN,WYMAX,SIZCHR,MARK
C---
IF(IWNUM.LE.0) THEN
VXMIN=0.
VXMAX=1.
VYMIN=0.
VYMAX=1.
ELSE
TMP=WINLOC(3,IWNUM)-WINLOC(1,IWNUM)
VXMIN=WINLOC(1,IWNUM)+TMP*BOXVP(1,IWNUM)
VXMAX=WINLOC(1,IWNUM)+TMP*BOXVP(3,IWNUM)
TMP=WINLOC(4,IWNUM)-WINLOC(2,IWNUM)
VYMIN=WINLOC(2,IWNUM)+TMP*BOXVP(2,IWNUM)
VYMAX=WINLOC(2,IWNUM)+TMP*BOXVP(4,IWNUM)
END IF
CALL PGVPORT( VXMIN, VXMAX, VYMIN, VYMAX)
C---
IF(IWNUM.LE.0) THEN
WXMIN=0.
WXMAX=1.
WYMIN=0.
WYMAX=1.
ELSE
WXMIN=XYSCAL(1,IWNUM)
WYMIN=XYSCAL(2,IWNUM)
WXMAX=XYSCAL(3,IWNUM)
WYMAX=XYSCAL(4,IWNUM)
IF(LOGX(IWNUM).NE.0) THEN
WXMIN=LOG10(MAX(WXMIN,RMNLOG))
WXMAX=LOG10(MAX(WXMAX,RMNLOG))
END IF
IF(LOGY(IWNUM).NE.0) THEN
WYMIN=LOG10(MAX(WYMIN,RMNLOG))
WYMAX=LOG10(MAX(WYMAX,RMNLOG))
END IF
END IF
IF((WXMIN.NE.WXMAX) .AND. (WYMIN.NE.WYMAX)) THEN
IF ( iwnum.EQ.0 .OR. Iadj(iwnum).EQ.0 ) THEN
CALL PGWINDOW(WXMIN,WXMAX,WYMIN,WYMAX)
ELSE
C Do window adjust, and reset BOXVP to be correct value.
CALL PGWNAD(WXMIN,WXMAX,WYMIN,WYMAX)
CALL PGQVP(0, VXMIN, VXMAX, VYMIN, VYMAX)
TMP=WINLOC(3,IWNUM)-WINLOC(1,IWNUM)
BOXVP(1,IWNUM) = (VXMIN-WINLOC(1,IWNUM))/TMP
BOXVP(3,IWNUM) = (VXMAX-WINLOC(1,IWNUM))/TMP
TMP=WINLOC(4,IWNUM)-WINLOC(2,IWNUM)
BOXVP(2,IWNUM) = (VYMIN-WINLOC(2,IWNUM))/TMP
BOXVP(4,IWNUM) = (VYMAX-WINLOC(2,IWNUM))/TMP
END IF
ELSE
WRITE(*,*) 'ERROR, Bad window size',WXMIN,WXMAX,WYMIN,WYMAX
WRITE(*,*) '- IWNUM=',IWNUM
END IF
RETURN
END
fv5.5/tcltk/plt/plconb.f 0000644 0002207 0000036 00000016614 13224715127 014075 0 ustar birby lhea C*PLCONB -- contour map of a 2D data array, with blanking
C+
SUBROUTINE PLCONB (Yray, IDIM, JDIM, I1, I2, J1, J2,
1 C, Mxlev, TR, BLANK, Nrow, Itype, Iftg,
2 Icomp, Pval, Nterm,
3 Icocon, Ilscon, Rlwcon )
INTEGER IDIM, JDIM, I1, I2, J1, J2, Mxlev
INTEGER Nrow, Itype, Iftg, Icomp(*), Nterm
INTEGER Icocon(*), Ilscon(*)
REAL Yray(IDIM,JDIM), C(*), TR(6), BLANK, Pval(*)
REAL Rlwcon(*)
C
C Draw a contour map of an array. This routine is the same as PGCONS,
C except that array elements that have the "magic value" defined by
C argument BLANK are ignored, making gaps in the contour map. The
C routine may be useful for data measured on most but not all of the
C points of a grid.
C
C Arguments:
C IDIM (input) : first dimension of A.
C JDIM (input) : second dimension of A.
C I1,I2 (input) : range of first index to be contoured (inclusive).
C J1,J2 (input) : range of second index to be contoured (inclusive).
C C (input) : array of contour levels (in the same units as the
C data in array A); dimension at least NC.
C NC (input) : number of contour levels (less than or equal to
C dimension of C). The absolute value of this
C argument is used (for compatibility with PGCONT,
C where the sign of NC is significant).
C TR (input) : array defining a transformation between the I,J
C grid of the array and the world coordinates. The
C world coordinates of the array point A(I,J) are
C given by:
C X = TR(1) + TR(2)*I + TR(3)*J
C Y = TR(4) + TR(5)*I + TR(6)*J
C Usually TR(3) and TR(5) are zero - unless the
C coordinate transformation involves a rotation
C or shear.
C BLANK (input) : elements of array A that are exactly equal to
C this value are ignored (blanked).
C--
C 1998-10-19 - Extracted from PGCONB [AFT].
C 21-Sep-1989 - Derived from PGCONS [TJP].
C-----------------------------------------------------------------------
REAL FNFIT
INTEGER MXDIM
PARAMETER (MXDIM=2)
C
INTEGER I, IC, ICORN, IDELT(6), iyoff, J, K, nc, NPT
INTEGER IOFF(8), JOFF(8), IENC, ITMP, JTMP, ILO, ITOT
INTEGER inew, ndim
LOGICAL PGNOTO
REAL CTR, DELTA, DVAL(5), XX, YY, X(4), XT(MXDIM), Y(4)
REAL atmp
INTRINSIC ABS
DATA IDELT/0,-1,-1,0,0,-1/
DATA IOFF/-2,-2,-1,-1, 0, 0, 1, 1/
DATA JOFF/ 0,-1,-2, 1,-2, 1,-1, 0/
C
C Check arguments.
C
IF (PGNOTO('PLCONB')) RETURN
IF (I1.LT.1 .OR. I2.GT.IDIM .OR. I1.GE.I2 .OR.
1 J1.LT.1 .OR. J2.GT.JDIM .OR. J1.GE.J2) RETURN
C
DO I = 1,Mxlev
IF ( C(I).EQ.Blank ) THEN
nc = i-1
GOTO 105
END IF
END DO
nc = Mxlev
105 CONTINUE
IF (NC.EQ.0) RETURN
CALL PGBBUF
C
DO 130 J=J1+1,J2
DO 130 I=I1+1,I2
IF ( Itype.EQ.0 ) THEN
DVAL(1) = Yray(I-1,J)
DVAL(2) = Yray(I-1,J-1)
DVAL(3) = Yray(I,J-1)
DVAL(4) = Yray(I,J)
DVAL(5) = DVAL(1)
ELSE IF ( Itype.GT.0 ) THEN
CALL PLTXCC(Yray, (j-1)*Nrow+i-1, iftg, xt, ndim, iyoff)
DVAL(1) = FNFIT(xt, Icomp, Pval, Nterm)
CALL PLTXCC(Yray, (j-2)*Nrow+i-1, iftg, xt, ndim, iyoff)
DVAL(2) = FNFIT(xt, Icomp, Pval, Nterm)
CALL PLTXCC(Yray, (j-2)*Nrow+i, iftg, xt, ndim, iyoff)
DVAL(3) = FNFIT(xt, Icomp, Pval, Nterm)
CALL PLTXCC(Yray, (j-1)*Nrow+i, iftg, xt, ndim, iyoff)
DVAL(4) = FNFIT(xt, Icomp, Pval, Nterm)
DVAL(5) = DVAL(1)
ELSE
CALL PLTXCC(Yray, (j-1)*Nrow+i-1, iftg, xt, ndim, iyoff)
DVAL(1) = Yray(I-1,J) - FNFIT(xt, Icomp, Pval, Nterm)
CALL PLTXCC(Yray, (j-2)*Nrow+i-1, iftg, xt, ndim, iyoff)
DVAL(2) = Yray(I-1,J-1) - FNFIT(xt, Icomp, Pval, Nterm)
CALL PLTXCC(Yray, (j-2)*Nrow+i, iftg, xt, ndim, iyoff)
DVAL(3) = Yray(I,J-1) - FNFIT(xt, Icomp, Pval, Nterm)
CALL PLTXCC(Yray, (j-1)*Nrow+i, iftg, xt, ndim, iyoff)
DVAL(4) = Yray(I,J) - FNFIT(xt, Icomp, Pval, Nterm)
DVAL(5) = DVAL(1)
END IF
C
IF (DVAL(1).EQ.BLANK .OR. DVAL(2).EQ.BLANK .OR.
1 DVAL(3).EQ.BLANK .OR. DVAL(4).EQ.BLANK) GOTO 130
DO 110 IC=1,ABS(NC)
inew = 1
CTR = C(IC)
NPT = 0
DO 120 ICORN=1,4
IF( (DVAL(ICORN).LT.CTR .AND. DVAL(ICORN+1).LT.CTR)
1 .OR.(DVAL(ICORN).GE.CTR .AND. DVAL(ICORN+1).GE.CTR) ) GOTO 120
IF ( inew.NE.0 ) THEN
CALL PLTSCI(icocon(IC))
CALL PLTSLS(ilscon(ic))
CALL PLTSLW(rlwcon(IC))
inew = 0
END IF
NPT=NPT+1
DELTA = (CTR-DVAL(ICORN))/(DVAL(ICORN+1)-DVAL(ICORN))
GOTO (60,70,60,70), ICORN
C
60 XX = I+IDELT(ICORN+1)
YY = REAL(J+IDELT(ICORN)) +
1 DELTA*REAL(IDELT(ICORN+1)-IDELT(ICORN))
GOTO 80
C
70 XX = REAL(I+IDELT(ICORN+1)) +
1 DELTA*REAL(IDELT(ICORN+2)-IDELT(ICORN+1))
YY = J+IDELT(ICORN)
C
80 X(NPT) = TR(1) + TR(2)*XX + TR(3)*YY
Y(NPT) = TR(4) + TR(5)*XX + TR(6)*YY
C
120 CONTINUE
IF (NPT.EQ.2) THEN
C -- Contour crosses two sides of cell. Draw line-segment.
CALL PGMOVE(X(1),Y(1))
CALL PGDRAW(X(2),Y(2))
ELSE IF (NPT.EQ.4) THEN
C -- The 'ambiguous' case. The routine must draw two line
C segments here and there are two ways to do so. The
C following 4 lines would implement the original PGPLOT
C method:
C CALL PGCP(0,X(1),Y(1),CTR)
C CALL PGCP(1,X(2),Y(2),CTR)
C CALL PGCP(0,X(3),Y(3),CTR)
C CALL PGCP(1,X(4),Y(4),CTR)
C -- Choose between \\ and // based on the 8 points just
C outside the current box. If half or more of these points
C lie below the contour level, then draw the lines such that
C the high corners lie between the lines, otherwise, draw
C the lines such that the low corners are enclosed. Care is
C taken to avoid going off the edge.
ITOT=0
ILO=0
DO 140 K=1,8
ITMP=I+IOFF(K)
JTMP=J+JOFF(K)
IF(ITMP.LT.I1 .OR. ITMP.GT.I2) GOTO 140
IF(JTMP.LT.J1 .OR. JTMP.GT.J2) GOTO 140
CALL PLTXCC(Yray,(i-1)*Nrow+j, iftg, xt, ndim, iyoff)
atmp = FNFIT(xt, Icomp, Pval, Nterm)
IF(atmp.EQ.BLANK) GOTO 140
ITOT=ITOT+1
IF(atmp.LT.CTR) ILO=ILO+1
140 CONTINUE
IENC=+1
IF(ILO.LT.ITOT/2) IENC=-1
IF(IENC.LT.0 .AND. DVAL(1).LT.CTR .OR.
: IENC.GT.0 .AND. DVAL(1).GE.CTR) THEN
CALL PGMOVE(X(1),Y(1))
CALL PGDRAW(X(2),Y(2))
CALL PGMOVE(X(3),Y(3))
CALL PGDRAW(X(4),Y(4))
ELSE
CALL PGMOVE(X(1),Y(1))
CALL PGDRAW(X(4),Y(4))
CALL PGMOVE(X(3),Y(3))
CALL PGDRAW(X(2),Y(2))
END IF
END IF
110 CONTINUE
130 CONTINUE
C
CALL PGEBUF
END
fv5.5/tcltk/plt/ploger.f 0000644 0002207 0000036 00000003337 13224715127 014106 0 ustar birby lhea SUBROUTINE PLOGER(CTOK, LTOK, IDOALL, ICWIN, MXWIN,
: CXOPT, LOGX, CYOPT, LOGY, IER)
CHARACTER CTOK*(*), CXOPT(*)*(*), CYOPT(*)*(*)
INTEGER LTOK, IDOALL, ICWIN, MXWIN, IER
INTEGER LOGX(*), LOGY(*)
C---
C Sets the log flag for use in PLT
C---
REAL FPNUM
C
CHARACTER CPEEK*2, CV*1
INTEGER IDOX, IDOY, ILOGIT, ITMP, IWNUM, LPEEK
C---
IER=0
IDOX=1
IDOY=1
100 CALL GTCHAR(CTOK,LTOK)
CALL UPC(CTOK)
IF(CTOK(1:1).EQ.'X') THEN
IDOX=IDOX+1
IDOY=IDOY-1
GOTO 100
ELSE IF(CTOK(1:1).EQ.'Y') THEN
IDOX=IDOX-1
IDOY=IDOY+1
GOTO 100
END IF
C---
CALL GTPEEK(CPEEK, LPEEK)
IF(CTOK(1:2).EQ.'OF') THEN
ILOGIT=0
CV=' '
ELSE
ILOGIT=1
CV='L'
END IF
C---
IF(LPEEK.EQ.0 .AND. IDOALL.NE.0) THEN
DO IWNUM=1,MXWIN
IF(IDOX.NE.0) THEN
LOGX(IWNUM)=ILOGIT
CXOPT(IWNUM)(6:6)=CV
END IF
IF(IDOY.NE.0) THEN
LOGY(IWNUM)=ILOGIT
CYOPT(IWNUM)(6:6)=CV
END IF
END DO
ELSE
IWNUM=ICWIN
150 IF(LPEEK.GT.0) THEN
CALL GTCHAR(CTOK, LTOK)
IF(LTOK.LE.0) GOTO 900
ITMP=FPNUM(CTOK,LTOK,IER)
IF(IER.NE.0) GOTO 900
IF(ITMP.GT.0 .AND. ITMP.LE.MXWIN) IWNUM=ITMP
END IF
IF(IDOX.NE.0) THEN
LOGX(IWNUM)=ILOGIT
CXOPT(IWNUM)(6:6)=CV
END IF
IF(IDOY.NE.0) THEN
LOGY(IWNUM)=ILOGIT
CYOPT(IWNUM)(6:6)=CV
END IF
IF(LPEEK.NE.0) GOTO 150
END IF
C---
900 CONTINUE
RETURN
END
fv5.5/tcltk/plt/plt.f 0000644 0002207 0000036 00000445053 13224715127 013422 0 ustar birby lhea SUBROUTINE PLTVER(Cvers, Lvers)
CHARACTER Cvers*(*)
INTEGER Lvers
C---
C Return the current PLT version number.
C---
C Cvers O The version number
C Lvers O Number of valid characters in cvers
C---
C 1998-05-28 - extracted from PLT - [AFT]
C---
Cvers = '2015-06-12'
Lvers = 10
END
C*********
SUBROUTINE PLT(Yray, Iery, Mxrow, Npts, Nvec, Cmd, Ncmd, Ier)
IMPLICIT NONE
REAL Yray(*)
INTEGER Iery(*), Mxrow, Npts, Nvec, Ncmd, Ier
CHARACTER Cmd(*)*(*)
C---
C General plot subroutine.
C---
C Yray(*) I The data array. The array should be dimensioned
C Y(Mxrow,MXCOL) where Mxrow and MXCOL are the actual
C sizes of the arrays in the calling program.
C MXCOL = Nvec+NSERR+2*NTERR where NSERR is the number
C of vectors that have symmetric errors and NTERR
C is the number of vectors that have two-sided errors.
C Iery(*) I = -1 assume errors are SQRT(Y)
C = 0 no errors.
C = +1 explicit symmetric errors.
C = +2 for two-sided errors
C Mxrow I The actual first dimension of the Y array.
C Npts I The number of points to plot (Npts< = Mxrow).
C Nvec I The number of vectors to be plotted.
C Cmd(*) I Array of commands.
C Ncmd I Number of commands.
C Ier O Error flag, = -1 if user entered EOF, = 0 otherwise.
C---
C [AFT]
C---
C- The NO data flag.
REAL NO
PARAMETER (NO = -1.2E-34)
C- Only allow up to two dimensional data.
INTEGER MXDIM
PARAMETER (MXDIM=2)
C- The minimum number that can be LOG'ed.
REAL RMNLOG
PARAMETER (RMNLOG = 1.E-36)
C- Max number of model parameters.
INTEGER MXPAR
PARAMETER (MXPAR = 120)
C- Number of independent plot groups (colors).
C- NOTE, pltxc.f must also define MXGRP to be equal to this value.
INTEGER MXGRP
PARAMETER (MXGRP = 500)
C- Max number of numbered labels.
INTEGER MXLAB
PARAMETER (MXLAB = 600)
C- Max number of simultaneous models that can be plotted
INTEGER MXMOD
PARAMETER (MXMOD = 4)
C- Max number of 2D (contour) plots. Must be less than MXGRP.
INTEGER MX2D
PARAMETER (MX2D = 10)
C- Max number of contour levels
INTEGER MXLEV
PARAMETER (MXLEV = 32)
C- Max number of windows
INTEGER MXWIN
PARAMETER (MXWIN = 40)
C Derived value
INTEGER MXVAL
PARAMETER (MXVAL=MXPAR*MXMOD)
C
CHARACTER CPARM*2
REAL FPNUM, FNFIT
INTEGER IAND, IFGRP, IOFSET, IOR, ISNUM, LENACT
C
C*** For 2D plots
CHARACTER cctnam(MX2D)*128
REAL rlvcon(MXLEV,MX2D), rlwcon(MXLEV,MX2D)
REAL tr(6), zscale(2,MX2D), rota(MX2D)
INTEGER icont(MX2D), image(MX2D)
INTEGER icocon(MXLEV,MX2D),ilscon(MXLEV,0:MX2D),isuba(4,0:MX2D)
INTEGER lctnam(MX2D), icbar(MX2D), itfun(MX2D)
C*** For each group
CHARACTER cglab(MXGRP)*80
REAL flimit(MXGRP), szmark(MXGRP)
REAL widlin(MXGRP)
C The actual data MIN and MAX values
REAL xymnmx(4,MXGRP)
C Data MIN and MAX values including errors.
REAL ermnmx(4, MXGRP)
INTEGER icol(MXGRP), igrpos(3,MXGRP), imark(MXGRP)
INTEGER ipmark(MXGRP)
INTEGER ipyer(MXGRP), ipwin(MXGRP), ispecg(MXGRP)
INTEGER line(MXGRP), lsty(MXGRP)
INTEGER ipmod(MXGRP)
C*** For each numbered label
CHARACTER CLABEL(MXLAB)*80
REAL FLABEL(7,MXLAB)
INTEGER ILABEL(7,MXLAB)
C*** For each model
REAL PVAL(MXPAR,MXMOD), PLIM(3,MXPAR,MXMOD)
INTEGER ICOMP(2*MXPAR,MXMOD), nterm(MXMOD)
SAVE PVAL, PLIM, ICOMP, nterm
INTEGER ifitg(MXMOD)
C*** For each window
CHARACTER CTLAB(MXWIN)*80, CXLAB(MXWIN)*80, CYLAB(MXWIN)*80
CHARACTER COTLAB(MXWIN)*80, COXLAB(MXWIN)*80, COYLAB(MXWIN)*80
CHARACTER CFNAM(MXWIN)*80
CHARACTER CXOPT(MXWIN)*10, CYOPT(MXWIN)*10
REAL BOXVP(4,MXWIN), WINLOC(4,MXWIN), XYSCAL(4,MXWIN)
REAL GRIDX(MXWIN), GRIDY(MXWIN)
INTEGER imaster(2,MXWIN)
INTEGER iactw(MXWIN), IWADJ(MXWIN)
INTEGER LOGX(MXWIN), LOGY(MXWIN), NSUBX(MXWIN), NSUBY(MXWIN)
C---
CHARACTER ctmp*255, ctok*128, CSCR1*128, CSCR2*128
CHARACTER CRLAB*80
CHARACTER CFILE*72, CHLIB*128
CHARACTER CHARD*256, cpfile*256, CPSAV*256
CHARACTER CPROM*16
CHARACTER CDISK*256, CDIR*12, CEXT*12
INTEGER LCDISK
CHARACTER CXOPT1*10, CYOPT1*10, CFONT*8
DOUBLE PRECISION dsum
REAL TOT(16)
C-
C For now only allow 2D arrays
REAL pmin(2), pmax(2), XT(2), X1(2)
C For SCR
REAL scrcol(3,0:15)
C-
REAL RED, GRN, BLU
REAL CA, COR, CSIZE, DEM, FCOL, Fnew
REAL OFF, PGPAPA, PGPAPW, PYLAB
REAL RGAP, RMARK, RTD, SA, SLOP
REAL TMP, TMP1, TMP2, WIDTH
REAL TXMAX, TXMIN, TYMAX, TYMIN
REAL XLAS, XHI, xtmp, XLO
REAL XCEN, XDEL, XH, XL, xmerr, xperr, XRANGE, XSPAC
REAL YCEN, YDEL, YH, YL, YMERR, YPERR, YRANGE, YSPAC, YT
REAL YOFF, YSLOP, YLONG
REAL VIEWX, VIEWY, VXLAS, VYLAS
REAL WINX, WINY, WXMIN, WXMAX, WYMIN, WYMAX
C-
INTEGER I, I1, I2, i2dind, i2drow, IBAD, ibcol, IC
INTEGER ic2dg, iclab, iclear, icmd, ICMOD, ICNT, icsub
INTEGER icwin, icyvec, idoall, idoend, IGAP
INTEGER idolin, IDOER, IDOWIN, IDOX, IDOY
INTEGER IE, IFIRST, iftg, ig, igroup, IGCOL, IGLS
INTEGER ILO, IHI, im, imnmx, imnum, IMX, IND, INITAK
INTEGER ioff, ION, IOPEN, IOS, ipall, IPLAB, IPZERO
INTEGER IS, iscr, ISIGN, iskip, ISTART, ITIME, itmp, ITRANS
INTEGER iwnum, ixvec, iy0, iyi, iyoff, iystep
INTEGER J1, J2, K, LERX, lery, LFILE, LOOP
INTEGER LPFILE, LPROM, LSCR1, LSCR2, ltmp, ltok, LUN
INTEGER NASUB, NDIG, ndim, nfpl, new, newmod, ngroup
INTEGER NMAX, NROW, NSTOP, NVERT, nxstep, nystep, LASWIN
LOGICAL QALL,QHARD
C
DATA PVAL/MXVAL*1./
DATA RTD/57.29577951/
C The directory where the help libraries are located
C DATA CDISK/'$XANTOP'/, CDIR/'doc'/
DATA CDIR/'.'/
C LHEA_HELP points directly to the directory containing the plt
C help file, so "CDIR" is "."
C LEB 5/7/97
C going to try to allow environment variables to determine
C CHLIB. will try XANBIN first and if that's not set we'll
C use FTOOLS; the idea is for this to work for both unix
C and vms
C jdd 1-22-97
CALL TRLOG('LHEA_HELP', 9, CDISK, LCDISK)
C Test to see that we got something back -- jdd
IF ( LCDISK .EQ. 0 ) THEN
WRITE (*,*) 'ERROR in plt/plt.f:'
WRITE (*,*) ' Environment variable $LHEA_HELP not defined.'
END IF
C---
11 FORMAT(A)
C Turn of GTBUF's standalone processing, we want $ and @ to work
CALL GTBUFNOTSTAND
C---
C- No errors (yet!)
Ier = 0
C- Create help library name
CHLIB = 'plt.hlp'
CALL PTEND(CDISK, CDIR, CHLIB)
C---
C- Set the XPARSE default extension
CALL XGETIN(CEXT)
CALL XSETIN('pco')
C---
C- Default is one group per vector
ngroup = MIN(Nvec,MXGRP-MXMOD)
CALL PLTXCI(Mxrow)
C- Default Gap = 2.5%, IGAP=0 don't include errors.
RGAP = 0.025
IGAP = 0
C- Paper size = 0.0 means use PGPLOT default
PGPAPW = 0.0
PGPAPA = 1.0
C- No active 2D subarrays.
NASUB = 0
C- The current 2D group has not been defined yet. This is the default
C- group for both CONtour and IMAge commands.
ic2dg = 0
DO ic = 1, MX2D
C- No rotation
rota(ic)=0.0
C- No contour and/or image plots
icont(ic) = 0
image(ic) = 0
lctnam(ic) = 0
C- linear image transform function
itfun(ic) = 0
C No color bar
icbar(ic) = 0
C- Default contour settings
DO I = 1, MXLEV
rlvcon(I,ic) = NO
icocon(I,ic) = I
ilscon(I,ic) = 1
rlwcon(I,ic) = 1.
zscale(1,ic) = 0.
zscale(2,ic) = 1.
END DO
END DO
C Special solid line style for default model contours.
DO I=1, MXLEV
ilscon(I,0) = 1
END DO
C
C Scan error array for largest possible contour plot. Number of rows is
C easy. The problem is to find the largest group of adjacent columns
C that all have the same error. Isuba(2,x) and Isuba(4,x) is the
C number of the vector (not the column),
isuba(1,0) = 1
isuba(3,0) = Npts
itmp = Iery(1)
ICNT = 1
IMX = 0
ISTART = 1
isuba(2,0) = 1
isuba(4,0) = Nvec
DO I = 2,Nvec
IF ( Iery(I).EQ.itmp ) THEN
ICNT = ICNT + 1
IF ( ICNT.GT.IMX ) THEN
isuba(2,0) = ISTART
isuba(4,0) = I
IMX = ICNT
END IF
ELSE
ICNT = 0
itmp = Iery(I)
ISTART = I
END IF
END DO
C- Commands like R X affect all the windows.
idoall = 1
C- Set Skip flag to zero. Can skip either Single, Double, or Off.
iskip = 0
C- Have not tried to translate PGPLOT_TYPE logical name
ITRANS = 0
C- LASWIN<>0 if Plot Vert is active
LASWIN = 0
CALL PGQINF('STATE', ctok, ltok)
IF(ctok(1:4).EQ.'OPEN') THEN
C- Plot device open, leave it open when PLT exits.
IOPEN = 1
idoend = 0
CALL PGASK(.FALSE.)
CALL PGQINF('DEV/TYPE', cpfile, LPFILE)
ELSE
C- Plot device closed, do pgend when PLT exits.
IOPEN = 0
idoend = 1
cpfile = ' '
LPFILE = 0
END IF
C- Default font
CFONT = ' '
C- Don't plot vectors that have color index zero.
IPZERO = 0
C- Default to background color of white.
ibcol = 0
C- Set imnmx = iskip to indicate that data MIN and MAX values have been
C- set for that value of iskip.
imnmx = -1
C- BIT0<>0 plot labels, BIT1<>0 plot parm labels
IPLAB = 3
C- Grid color and lstyle
IGCOL = 1
IGLS = 1
C- Position of the Y label
PYLAB = 2.0
C- Do not plot NO data values.
QALL = .FALSE.
C- Default character size
CSIZE = 1.0
C- Default line width
WIDTH = 1.0
C- Time stamp on
ITIME = 1
C- Current window is number 1
icwin = 1
C- All windows fill the screen
DO I = 1,MXWIN
C Assume most windows are inactive. Note, iactw must be updated every
C time the user does something that might change the number of windows
C being plotted, such as COlor ON|OFF, YAXA, IMAG, CONT, PLOT V, PLOT O.
iactw(I) = 0
C Default viewport
BOXVP(1,I) = 0.1
BOXVP(2,I) = 0.1
BOXVP(3,I) = 0.9
BOXVP(4,I) = 0.9
C- Init number of major and minor tic marks. Zero means use default.
GRIDX(I) = 0.
GRIDY(I) = 0.
NSUBX(I) = 0
NSUBY(I) = 0
C- No window adjust
IWADJ(I) = 0
C- Title
CTLAB(I) = ' '
COTLAB(I) = ' '
C- File
CFNAM(I) = ' '
C- Label X-axis tic marks, CXOPT(6:6) = 'L'|' ', CXOPT(7:7) = 'G'|' '
CXOPT(I) = 'BCSTN'
CXLAB(I) = ' '
COXLAB(I) = ' '
C- Label Y-axis tic marks, CYOPY(8:8) = 'V'|' '
CYOPT(I) = 'BCSTN'
CYLAB(I) = ' '
COYLAB(I) = ' '
C- linear X and Y
LOGX(I) = 0
LOGY(I) = 0
C- All windows fill the screen
WINLOC(1,I) = 0.
WINLOC(2,I) = 0
WINLOC(3,I) = 1.
WINLOC(4,I) = 1.
XYSCAL(1,I) = NO
XYSCAL(2,I) = NO
XYSCAL(3,I) = NO
XYSCAL(4,I) = NO
C- No master/slave windows (yet!). =0 independent, =-1 master, >0 owner
imaster(1,i) = 0
imaster(2,i) = 0
END DO
C Default first window is active.
iactw(1) = 1
C---
C--- The label options are (where i = group number):
C ILABEL(1,i) =0 inactive, =n (n>0) window n coords, =-1 viewport
C ILABEL(2,i) 1:3 Justification (Left, center, right)
C ILABEL(3,i) 1,3,5 Center (Base, Center, Top)
C ILABEL(4,i) 0:15 Color
C ILABEL(5,i) 1:5 line style.
C ILABEL(6,i) -1:30 Marker type (-1 = no marker)
C ILABEL(7,i) =0 normal, =1 FLABEL(5,i) FLABEL(6,i) specify line endpoint
C---
C FLABEL(1,i) Character X-position (default = 0.0)
C FLABEL(2,i) Character Y-position (default = 0.0)
C FLABEL(3,i) Rotatation angle of label (default = 0.0)
C FLABEL(4,i) Character size (default = 1.0)
C FLABEL(5,i) line angle
C FLABEL(6,i) line length in viewport units (default = 0.0 no line)
C FLABEL(7,i) Marker size
C---
DO i=1,MXLAB
ILABEL(1,i) = 0
ILABEL(2,i) = 2
ILABEL(3,i) = 3
ILABEL(4,i) = 1
ILABEL(5,i) = 1
ILABEL(6,i) = -1
ILABEL(7,i) = 0
FLABEL(1,i) = 0.0
FLABEL(2,i) = 0.0
FLABEL(3,i) = 0.0
FLABEL(4,i) = 1.0
FLABEL(6,i) = 0.0
FLABEL(7,i) = 1.0
END DO
C- The following does a virtual "Xaxis 1".
ixvec = 1
C-
DO ig=1,MXGRP
C- Zero out the plot window array
ipwin(ig) = 0
C- No group labels
cglab(ig) = ' '
C- Default colors (PGPLOT only defines color indices up to 15).
IF ( ig.LE.15 ) THEN
icol(ig) = ig
ELSE
icol(ig) = 1
END IF
C- Don't plot markers, but if you do, default marker type is 2
ipmark(ig) = 0
imark(ig) = 2
C- line =0 line off, =1 line on, =-1 Stepped line plot, >1 smooth line.
line(ig) = 0
C- Solid line
lsty(ig) = 1
C- No upper limits
flimit(ig) = 0.0
C- Default marker size
szmark(ig) = 1.0
C- Use global line width
widlin(ig) = 0.0
C- No model has been defined
ipmod(ig) = 0
C- Standard groups
ispecg(ig) = 0
C- Default to all groups being undefined.
igrpos(1,ig) = -1
END DO
newmod = 0
C-
DO ig=1,ngroup
C- Plot all active groups in the first window.
ipwin(ig) = 1
C The default X coordinate is the first vector in the array hence 1D.
CALL PLTXCN(ig, 1, 0)
itmp = iofset(ixvec, Iery, ixvec, Mxrow)
CALL PLTXCG(ig, 1, ixvec, itmp, Iery)
C igrpos contains info on how to find plot groups in the Y array.
C igrpos(1,ig) is location of the zeroth point of the group
C igrpos(2,ig) is the number of points in the group
C igrpos(3,ig) is the vector number from which the group was created
igrpos(1,ig) = IOFSET(ig, Iery, Nvec, Mxrow)
igrpos(2,ig) = Npts
igrpos(3,ig) = ig
C- Plot errors, = -1 Root, = 0 no errors, = 1 bars, = 2 diamonds
ipyer(ig) = MIN(Iery(ig),1)
END DO
C- The previous loop plots all groups, turn off the xaxis group.
ipwin(ixvec) = -ABS(ipwin(ixvec))
C- Make sure no models are defined.
DO i = 1,MXMOD
nterm(i) = 0
ifitg(i) = 0
C The last MXMOD groups are hardwired to plot models.
icol(MXGRP-MXMOD+1) = 1
END DO
C- Default current model
ICMOD = 1
C- Plot model at data values.
nfpl = 0
C- Default to 200 steps for integrate model
nxstep = 200
nystep = 200
C SCR
DO iscr=0,15
DO i=1,3
scrcol(i,iscr)=NO
END DO
END DO
C- Default labels.
CRLAB = ' '
C- Default prompt
CPROM = 'PLT>'
C- Get default hardcopy name
CALL PLTHAR(CHARD)
qhard = .FALSE.
icmd = 0
C---
90 CONTINUE
C Load the GTBUF command list
IF ( icmd.LT.Ncmd ) THEN
IF ( LENACT(Cmd(icmd+1)).LE.0 ) THEN
icmd = icmd+1
GOTO 90
END IF
CALL STWARN(1)
CALL LDBUF1(Cmd(icmd+1),Ier)
icmd = icmd+1-Ier
ELSE
C All commands loaded, go produce plot
icmd = -1
GOTO 600
END IF
C
100 CONTINUE
CALL GTBUF(CPROM,Ier)
IF(Ier.NE.0) THEN
C EOF
IF(Ier.LT.0) GOTO 900
C More commands to be loaded
IF(0.LE.icmd .AND. icmd.LE.Ncmd) GOTO 90
END IF
CALL GTCHAR(ctok,ltok)
IF(ltok.LE.0) GOTO 100
CALL UPC(ctok)
C
110 CONTINUE
C---
C- Ajdust window -----------------------------------------------------
IF ( ctok(1:1).EQ.'A' ) THEN
CALL GTCHAR(ctok,ltok)
IF ( ltok.LE.0 ) THEN
WRITE(*,*) 'Syntax: Ajust ON|OFF wlist'
GOTO 100
END IF
CALL UPC(ctok)
C- Scan for ON/OFf
IF(ctok(1:2).EQ.'ON') THEN
ISIGN = +1
ELSE IF(ctok(1:2).EQ.'OF') THEN
ISIGN = 0
END IF
C
CALL IRANGE(ctok,ltok,1,MXWIN,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXWIN))
IHI = MAX(1,MIN(IHI,MXWIN))
DO I = ILO,IHI
IWADJ(icwin) = ISIGN
END DO
C---
ELSE IF(ctok(1:1).EQ.'C') THEN
C- CLear device ------------------------------------------------------
IF(ctok(1:2).EQ.'CL') THEN
CALL PLTCLR
C---
C- CONtour -----------------------------------------------------------
ELSE IF(ctok(1:3).EQ.'CON') THEN
CALL GTCHAR(ctok,ltok)
IF ( ISNUM(ctok,ltok).NE.0 ) THEN
C CONtour # to change the currently active contour/image group.
itmp = FPNUM(ctok, ltok, Ier)
IF ( itmp.LE.0 .OR. itmp.GT.MX2D ) THEN
WRITE(*,*) 'Contour number must be in the range 1 to',
: MX2D
GOTO 100
END IF
CALL PLTXCC(Yray, 1, itmp, xt, ndim, iyoff)
IF ( ndim.EQ.1 ) THEN
WRITE(*,121) itmp
121 FORMAT(' Plot group ',I3,' is only one dimensional.')
GOTO 100
END IF
ic2dg = itmp
CALL GTCHAR(ctok,ltok)
END IF
IF ( ic2dg.EQ.0 ) THEN
C User has failed to define a 2D subarray. Overwrite the first group
C with the largest possible 2D array.
ic2dg = 1
isuba(1,ic2dg) = isuba(1,0)
isuba(2,ic2dg) = isuba(2,0)
isuba(3,ic2dg) = isuba(3,0)
isuba(4,ic2dg) = isuba(4,0)
igrpos(1,ic2dg) = IOFSET(isuba(2,0), Iery, Nvec, Mxrow) +
& isuba(1,0) - 1
igrpos(2,ic2dg) = (isuba(3,0)-isuba(1,0)+1)*
& (isuba(4,0)-isuba(2,0)+1)
igrpos(3,ic2dg) = isuba(2,0)
ispecg(ic2dg) = 3
CALL PLTXCN(ic2dg, 2, isuba(3,0)-isuba(1,0)+1)
CALL PLTXCL(ic2dg, 1, NO, NO)
CALL PLTXCL(ic2dg, 2, NO, NO)
imnmx = -1
END IF
ioff = 0
C
C This is the main loop for parsing the CONtour command. NOTE, it
C is important that the next argument is parsed, before jumping back
C here, otherwise an infinite loop results.
130 CONTINUE
IF ( ltok.EQ.0 ) THEN
C No more sub-commands.
IF ( ioff.EQ.0 ) THEN
C Activate the selected window.
icont(ic2dg) = 1
IF ( ipwin(ic2dg).LE.0 ) ipwin(ic2dg) = icwin
END IF
CALL ACTWIN(ipwin,ngroup,MXWIN,iactw)
GOTO 100
END IF
C
C Now parse sub-commands.
CALL UPC(ctok)
IF(ctok(1:1).EQ.'?') THEN
WRITE(*,*) 'Possible sub-commands are:'
WRITE(*,*) 'COlor, LEvels, lstyle, LWidth, OFf'
ELSE IF(ctok(1:2).EQ.'CO') THEN
C CONtour COlor
DO I = 1,MXLEV
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) THEN
IF(ISNUM(ctok, ltok).EQ.0) GOTO 130
icocon(I,ic2dg) = FPNUM(ctok,ltok,Ier)
END IF
END DO
ELSE IF(ctok(1:2).EQ.'LE') THEN
C CONtour LEvel
DO I = 1,MXLEV
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) THEN
IF(ISNUM(ctok, ltok).EQ.0) GOTO 130
rlvcon(I,ic2dg) = FPNUM(ctok,ltok,Ier)
END IF
END DO
ELSE IF(ctok(1:2).EQ.'LS') THEN
C CONtour lstyle
DO I = 1,MXLEV
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) THEN
IF(ISNUM(ctok, ltok).EQ.0) GOTO 130
ilscon(I,ic2dg) = FPNUM(ctok,ltok,Ier)
END IF
END DO
ELSE IF(ctok(1:2).EQ.'LW') THEN
C CONtour LWidth
DO I = 1,MXLEV
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) THEN
IF(ISNUM(ctok, ltok).EQ.0) GOTO 130
rlwcon(I,ic2dg) = FPNUM(ctok,ltok,Ier)
END IF
END DO
ELSE IF(ctok(1:2).EQ.'OF') THEN
C CONtour OFF (turn off all images in the current window)
ioff = 1
icont(ic2dg) = 0
IF ( icol(ic2dg).LE.0 .AND. image(ic2dg).LE.0 )
& ipwin(ic2dg) = -ABS(ipwin(ic2dg))
ELSE
WRITE(*,591) ctok(:ltok)
END IF
CALL GTCHAR(ctok,ltok)
GOTO 130
C---
C- COlor -------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'CO') THEN
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
FCOL = NO
IF(ctok(1:1).EQ.'?') THEN
CALL PLTSCI(-1)
ELSE IF(ctok(1:1).EQ.'M') THEN
CALL GTINT(icol(MXGRP-MXMOD+ICMOD),Ier)
ELSE IF(ISNUM(ctok,ltok).NE.0) THEN
FCOL = FPNUM(ctok,ltok,Ier)
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
END IF
C- Scan for ON/OFf
IF(ctok(1:2).EQ.'ON') THEN
ISIGN = +1
ELSE IF(ctok(1:2).EQ.'OF') THEN
ISIGN = -1
END IF
C- Find which vectors to color
160 CALL GTCHAR(ctok,ltok)
IF(ltok.LE.0) THEN
CALL ACTWIN(ipwin,ngroup,MXWIN,iactw)
ELSE
CALL UPC(ctok)
IF(ctok(1:1).EQ.'G') THEN
IGCOL = FCOL
ELSE IF(ctok(1:1).EQ.'M') THEN
icol(MXGRP-MXMOD+ICMOD) = FCOL
ELSE
CALL IRANGE(ctok,ltok,1,MXGRP-MXMOD,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXGRP-MXMOD))
IHI = MAX(1,MIN(IHI,MXGRP-MXMOD))
DO I = ILO,IHI
IF(FCOL.EQ.NO) THEN
IF(ISIGN.LT.0) THEN
icol(I) = -ABS(icol(I))
ipwin(I) = -ABS(ipwin(I))
ELSE
icol(I) = ABS(icol(I))
ipwin(I) = ABS(ipwin(I))
END IF
ELSE
IF(ISIGN.LT.0) THEN
icol(I) = -FCOL
ipwin(I) = -ABS(ipwin(I))
ELSE
icol(I) = FCOL
ipwin(I) = ABS(ipwin(I))
END IF
END IF
END DO
END IF
GOTO 160
END IF
ELSE IF(ctok(1:3).EQ.'CPD') THEN
C- CPD device --------------------------------------------------------
CALL GTCHAR(cpfile, ltok)
IF ( ltok.EQ.0 ) THEN
cpfile = ' '
ELSE IF ( cpfile(1:1).EQ.'?' ) THEN
CALL PGLDEV
GOTO 100
END IF
CALL PGEND
IF ( IOPEN.LT.0 ) CALL PLTTER('A')
IOPEN = 0
C---
C- Clear and Quit ----------------------------------------------------
ELSE IF(ctok(1:2).EQ.'CQ' .OR. ctok(1:2).EQ.'CE') THEN
CALL PLTCLR
GOTO 950
C---
C- Character Size ----------------------------------------------------
ELSE IF(ctok(1:2).EQ.'CS') THEN
CALL GTREAL(TMP, Ier)
IF(TMP.GT.0.) CSIZE = TMP
C---
C- CUrsor ------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'CU') THEN
loop = 1
LUN = 0
170 CONTINUE
CALL GTCHAR(ctok, ltok)
IF ( ltok.GT.0 ) THEN
CALL UPC(ctok(:ltok))
IF ( ctok(1:3).EQ.'WXY' ) THEN
CFILE = ' '
CALL GTCHAR(CFILE,LFILE)
C WHead or WEnviron
CALL XTEND(CFILE,'CUR')
CALL GETLUN(LUN)
CALL OPENWR(LUN,CFILE,'new',' ','LIST',0,0,IOS)
IF(IOS.NE.0) THEN
WRITE(*,*) 'PLT--Unable to open '//
: ctmp(:LENACT(ctmp))
GOTO 100
END IF
ELSE IF ( ctok(1:1).EQ.'N' ) THEN
CALL GTINT(loop, Ier)
ELSE
GOTO 590
END IF
GOTO 170
END IF
VXLAS = -1.
VYLAS = -1.
180 CONTINUE
CALL PLTCUR(WINLOC, BOXVP, XYSCAL, MXWIN, LOGX, LOGY,
: iactw, iwadj, iwnum, VIEWX, VIEWY, WINX, WINY, ctmp)
IF ( loop.GE.0 ) THEN
CALL UPC(ctmp(1:1))
IF ( INDEX('QX',ctmp(1:1)).GT. 0 .OR.
: VIEWX.EQ.VXLAS .AND. VIEWY.EQ.VYLAS ) THEN
IF ( LUN.GT.0 ) THEN
CLOSE(UNIT = LUN)
CALL FRELUN(LUN)
END IF
GOTO 100
END IF
END IF
C Write out information
WRITE(*,*) 'iwnum = ',iwnum
WRITE(*,*) 'VPOS = ',VIEWX,VIEWY
WRITE(*,*) 'WPOS = ',WINX,WINY
IF ( LUN.GT.0 .AND. ctmp(1:1).NE.'?' ) THEN
WRITE(LUN,*) WINX, WINY
END IF
IF ( ABS(loop).EQ.1 ) THEN
IF ( LUN.GT.0 ) THEN
CLOSE(UNIT = LUN)
CALL FRELUN(LUN)
END IF
GOTO 100
END IF
C Decrement loop counter
IF ( ctmp(1:1).NE.'?' ) THEN
IF ( loop.GT.0 ) THEN
loop = loop - 1
ELSE
loop = loop + 1
END IF
VXLAS = VIEWX
VYLAS = VIEWY
END IF
GOTO 180
C End 'C' commands
END IF
C---
C- DGroup ------------------------------------------------------------
ELSE IF ( ctok(1:2).EQ.'DG' ) THEN
CALL GTPEEK(ctmp,ltmp)
IF ( isnum(ctmp, ltmp).NE.0 ) THEN
CALL GTINT(icsub, ier)
IF ( icsub.LE.0 .OR. MXGRP-MXMOD.LT.icsub ) THEN
WRITE(*,*) 'The SUBarray group number must be ',
& 'in the range 1 to ',MXGRP-MXMOD,'.'
GOTO 100
END IF
ELSE
ctok = ' '
CALL GTCHAR(ctok, ltok)
ltok = MAX(1,ltok)
C Scan to see if name already exists
cscr1 = ctok(:ltok)
CALL UPC(cscr1(:ltok))
icsub = 0
DO ig= 1,ngroup
IF ( igrpos(1,ig).GE.0 ) THEN
cscr2 = cglab(ig)(:ltok)
CALL UPC(cscr2(:ltok))
IF ( cscr1(:ltok).EQ.cscr2(:ltok) ) THEN
icsub = ig
END IF
END IF
END DO
IF ( icsub.LE.0 ) THEN
WRITE(*,*) 'The DGroup command requires a group.'
GOTO 100
END IF
END IF
C
CALL GTPEEK(ctmp,ltmp)
CALL UPC(ctmp)
IF ( ctmp(1:1).EQ.'M' .OR. ctmp(1:1).EQ.'R' ) THEN
IF ( ctmp(1:1).EQ.'M' ) THEN
C DGroup # Model
ipmod(icsub) = icmod
ispecg(icsub) = 1
ELSE
C DGroup # Res
ipmod(icsub) = -icmod
ispecg(icsub) = 2
END IF
CALL GTCHAR(ctok, ltok)
CALL PLTXCD(ifitg(icmod), icsub)
igrpos(1, icsub) = igrpos(1, ifitg(icmod))
igrpos(2, icsub) = igrpos(2, ifitg(icmod))
igrpos(3, icsub) = igrpos(3, ifitg(icmod))
ipyer(icsub) = ipyer(ifitg(icmod))
IF ( icsub.LE.MX2D .AND. ifitg(icmod).LE.MX2D ) THEN
isuba(1,icsub) = isuba(1, ifitg(icmod))
isuba(2,icsub) = isuba(2, ifitg(icmod))
isuba(3,icsub) = isuba(3, ifitg(icmod))
isuba(4,icsub) = isuba(4, ifitg(icmod))
END IF
GOTO 185
ELSE
C Now read locations of two corners
I1 = 1
J1 = 1
CALL GTINT(I1,Ier)
CALL GTPEEK(ctmp,ltmp)
IF ( ltmp.LE.0 ) THEN
C If only one number is on the line then assume that is a column number.
j1 = i1
j1 = MIN(MAX(1,j1),Nvec)
j2 = j1
i1 = 1
i2 = Npts
ELSE
CALL GTINT(J1,Ier)
I1 = MIN(MAX(1,I1),Npts)
J1 = MIN(MAX(1,J1),Nvec)
I2 = Npts
J2 = Nvec
CALL GTINT(I2,Ier)
CALL GTINT(J2,Ier)
I2 = MIN(MAX(1,I2),Npts)
J2 = MIN(MAX(1,J2),Nvec)
itmp = Iery(j1)
DO I = J1, J2
IF ( Iery(I).NE.itmp ) THEN
WRITE(*,*)
: 'The errors are not the same on all vectors.'
WRITE(*,*) 'Not allowed to contour.'
GOTO 100
END IF
END DO
END IF
ispecg(icsub) = 3
END IF
C Got group and two corners, now define the subarray
IF ( J1.EQ.J2 ) THEN
C User defined a 1D array
CALL PLTXCN(icsub, 1, 0)
IF ( ixvec.NE.0 ) THEN
itmp = iofset(ixvec, Iery, ixvec, Mxrow)+I1-1
CALL PLTXCG(icsub, 1, ixvec, itmp, Iery)
END IF
igrpos(1,icsub) = IOFSET(j1, Iery, Nvec, Mxrow) + I1 - 1
igrpos(2,icsub) = I2-I1+1
igrpos(3,icsub) = j1
ELSE
C Must be 2D
CALL PLTXCN(icsub, 2, i2-i1+1)
isuba(1,icsub) = I1
isuba(2,icsub) = J1
isuba(3,icsub) = I2
isuba(4,icsub) = J2
igrpos(1,icsub) = IOFSET(J1, Iery, Nvec, Mxrow) + I1 - 1
igrpos(2,icsub) = (I2-I1+1)*(J2-J1+1)
igrpos(3,icsub) = isuba(2,icsub)
CALL PLTXCL(icsub, 1, NO, NO)
CALL PLTXCL(icsub, 2, NO, NO)
C Use the most recently defined 2D subarray as the default to contour/image
ic2dg = icsub
END IF
185 CONTINUE
ngroup = MAX(ngroup, icsub)
C Since we have (possibly) redefined the groups, force the reevaluation
C of data min/max values.
imnmx = -1
C- Device ------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'D' ) THEN
CALL GTCHAR(cpfile, ltok)
IF ( ltok.EQ.0 ) THEN
cpfile = ' '
ELSE IF ( cpfile(1:1).EQ.'?' ) THEN
CALL PGLDEV
GOTO 100
END IF
CALL PGEND
IF ( IOPEN.LT.0 ) CALL PLTTER('A')
IOPEN = 0
C---
C- EXit or Quit ------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'EX' .OR. ctok(1:1).EQ.'Q') THEN
GOTO 950
C---
C- Error -------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'E') THEN
IDOX = 0
IDOY = 0
190 CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'X') THEN
IDOX = 1
GOTO 190
ELSE IF(ctok(1:1).EQ.'Y') THEN
IDOY = 1
GOTO 190
END IF
IF ( IDOX.EQ.0 .AND. IDOY.EQ.0 ) THEN
IDOX = 1
IDOY = 1
END IF
IF(ctok(1:1).EQ.'D') THEN
new = 2
ELSE IF(ctok(1:1).EQ.'G') THEN
C Gehrels
new = -2
ELSE IF(ctok(1:2).EQ.'ON') THEN
new = 1
ELSE IF(ctok(1:2).EQ.'OF') THEN
new = 0
ELSE IF(ctok(1:1).EQ.'S') THEN
C Poisson.
new = -1
ELSE
GOTO 590
END IF
C- Now get [glist]
CALL GTCHAR(ctok,ltok)
210 CONTINUE
CALL UPC(ctok)
CALL IRANGE(ctok,ltok,1,ngroup,ILO,IHI,Ier)
IF(ILO.LT.1 .OR. IHI.LT.1) GOTO 590
ILO = MAX(1,MIN(ILO,MXGRP))
IHI = MAX(1,MIN(IHI,MXGRP))
DO igroup = ILO, IHI
IF ( igrpos(1,igroup).GE.0 ) THEN
IF ( IDOX.NE.0 ) CALL PLTXCP(igroup, 1, new)
IF ( IDOY.NE.0 ) THEN
lery = Iery(igrpos(3,igroup))
IF ( lery.EQ.0 ) THEN
C- If originally no errors, only plot statistical or no errors.
IF ( new.LE.0 ) ipyer(igroup) = new
ELSE
ipyer(igroup) = new
END IF
END IF
END IF
END DO
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) GOTO 210
C---
C- FNY ---------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'FN') THEN
IF(nterm(ICMOD).LE.0) THEN
WRITE(*,*) 'No model defined.'
ELSE
CALL GTREAL(xt(1),Ier)
xt(2) = 0.0
CALL GTREAL(xt(2),Ier)
WRITE(*,*) FNFIT(XT,ICOMP(1,ICMOD),
: PVAL(1,ICMOD),nterm(ICMOD))
END IF
C---
C- FOnt --------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'FO') THEN
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) THEN
IF(ctok(1:1).EQ.'?') THEN
CALL PLTFON(ctok)
ELSE
CFONT = ctok
IF(IOPEN.NE.0) CALL PLTFON(CFONT)
END IF
ELSE
CFONT = ' '
END IF
C---
C- FReeze ------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'FR') THEN
IF(nterm(ICMOD).LE.0) THEN
WRITE(*,411)
ELSE
CALL GTREST(ctok,ltok)
ctmp = 'FR '//ctok
CALL MODEL(ctmp,pmin,pmax,MXPAR,Cmd,Ncmd,Icmd,
& ICOMP(1,ICMOD),PVAL(1,ICMOD),PLIM(1,1,ICMOD),nterm(ICMOD))
END IF
C---
C- Fit ---------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'F') THEN
IF ( nterm(ICMOD).LE.0 ) THEN
WRITE(*,*) 'PLT--You must define a model first.'
GOTO 100
END IF
C
CALL DSCALE(Yray, Iery, Mxrow, MXWIN, MX2D, ngroup, MXPAR,
& igap, rgap, idoall, iskip, newmod, iactw, logx, logy, imaster,
& igrpos, ipwin, icont, image, ipmod, icomp, pval, nterm,
& imnmx, xymnmx, ermnmx, xyscal)
C
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF ( ctok(1:2).EQ.'ON' ) THEN
C Fit ON (plot the model in the same window as the group being fitted).
CALL GTINT(itmp,Ier)
IF ( itmp.GT.0 .AND. itmp.LE.ngroup ) THEN
ipwin(MXGRP-MXMOD+icmod) = ipwin(itmp)
ifitg(icmod) = itmp
ELSE
ipwin(MXGRP-MXMOD+icmod) = ABS(ipwin(MXGRP-MXMOD+icmod))
END IF
GOTO 100
ELSE IF ( ctok(1:2).EQ.'OF' ) THEN
C Fit OFf
ipwin(MXGRP-MXMOD+icmod) = -ABS(ipwin(MXGRP-MXMOD+icmod))
GOTO 100
ELSE IF ( ctok(1:1).EQ.'P' ) THEN
C Fit Plot #
CALL GTINT(nfpl,Ier)
GOTO 100
ELSE IF ( ctok(1:1).EQ.'E' ) THEN
C Obsolete Fit Error command
ctok = 'UNCER'
GOTO 110
END IF
C
ctok(ltok+1:) = ' '
CALL GTREST(ctok(ltok+2:),ltmp)
IF ( IOPEN.LT.0 ) CALL PLTTER('A')
CALL FIT(ctok, ifitg(icmod), Yray, Mxrow, ngroup, icwin,
: ipwin, ipyer, ipwin, igrpos, XYSCAL,
: ICOMP(1,ICMOD),PVAL(1,ICMOD),PLIM(1,1,ICMOD),nterm(ICMOD))
ipwin(MXGRP-MXMOD+icmod) = ipwin(ifitg(icmod))
ipall = 0
ICLEAR = 0
newmod = icmod
GOTO 650
C---
C- G -----------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'G') THEN
IF(ctok(1:2).EQ.'GA') THEN
C- GAp ---------------------------------------------------------------
230 CONTINUE
CALL GTCHAR(ctok,ltok)
IF ( ltok.GE.1 ) THEN
CALL UPC(ctok(:ltok))
IF ( ctok(1:1).EQ.'E' ) THEN
C Gap Error
IGAP = +1
CALL GTCHAR(ctok,ltok)
ELSE IF ( ctok(1:1).EQ.'N' ) THEN
C Gap Noerror
IGAP = 0
CALL GTCHAR(ctok,ltok)
ELSE IF ( ISNUM(ctok,ltok).NE.0 ) THEN
C Gap #
RGAP = FPNUM(ctok, ltok, Ier)
END IF
GOTO 230
END IF
ELSE IF(ctok(1:1).EQ.'G') THEN
C- Grid --------------------------------------------------------------
240 CALL GTCHAR(ctok,ltok)
IF(ltok.LE.0) GOTO 100
CALL UPC(ctok)
IF(ctok(1:2).EQ.'ON') THEN
C Grid ON
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CXOPT(i)(7:7) = 'G'
CYOPT(i)(7:7) = 'G'
END DO
ELSE
CXOPT(icwin)(7:7) = 'G'
CYOPT(icwin)(7:7) = 'G'
END IF
ELSE IF(ctok(1:2).EQ.'OF') THEN
C Grid OFf
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CXOPT(i)(7:7) = ' '
CYOPT(i)(7:7) = ' '
END DO
ELSE
CXOPT(icwin)(7:7) = ' '
CYOPT(icwin)(7:7) = ' '
END IF
ELSE IF(ctok(1:1).EQ.'X') THEN
C Grid X
CALL GTPEEK(ctmp, ltmp)
IF ( ISNUM(ctmp, ltmp).NE.0 ) THEN
CALL GTREAL(TMP, Ier)
IF(TMP.LT.0.) THEN
CXOPT(icwin)(4:4) = ' '
ELSE
CXOPT(icwin)(4:4) = 'T'
GRIDX(icwin) = TMP
END IF
itmp = -1
CALL GTINT(itmp,Ier)
IF(itmp.LT.0) THEN
CXOPT(icwin)(3:3) = ' '
ELSE
CXOPT(icwin)(3:3) = 'S'
NSUBX(icwin) = itmp
END IF
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CXOPT(i)(4:4) = CXOPT(icwin)(4:4)
GRIDX(i) = GRIDX(icwin)
CXOPT(i)(3:3) = CXOPT(icwin)(3:3)
NSUBX(i) = NSUBX(icwin)
END DO
END IF
ELSE
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok(:ltok))
IF ( ctok(1:2).EQ.'ON') THEN
C Grid X ON
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CXOPT(i)(7:7) = 'G'
END DO
ELSE
CXOPT(icwin)(7:7) = 'G'
END IF
ELSE IF ( ctok(1:2).EQ.'OF') THEN
C Grid X OFf
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CXOPT(i)(7:7) = ' '
END DO
ELSE
CXOPT(icwin)(7:7) = ' '
END IF
END IF
END IF
ELSE IF(ctok(1:1).EQ.'Y') THEN
C Grid Y
CALL GTPEEK(ctmp, ltmp)
IF ( ISNUM(ctmp, ltmp).NE.0 ) THEN
IF(ltok.GT.1) THEN
itmp = FPNUM(ctok(2:ltok),ltok-1,Ier)
iwnum = MAX(1,MIN(itmp,MXWIN))
ELSE
iwnum = icwin
END IF
CALL GTREAL(TMP,Ier)
IF(TMP.LT.0.) THEN
CYOPT(iwnum)(4:4) = ' '
ELSE
CYOPT(iwnum)(4:4) = 'T'
GRIDY(iwnum) = TMP
END IF
itmp = -1
CALL GTINT(itmp,Ier)
IF(itmp.LT.0) THEN
CYOPT(iwnum)(3:3) = ' '
ELSE
CYOPT(iwnum)(3:3) = 'S'
NSUBY(iwnum) = itmp
END IF
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CYOPT(i)(4:4) = CYOPT(icwin)(4:4)
GRIDY(i) = GRIDY(icwin)
CYOPT(i)(3:3) = CYOPT(icwin)(3:3)
NSUBY(i) = NSUBY(icwin)
END DO
END IF
ELSE
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok(:ltok))
IF ( ctok(1:2).EQ.'ON') THEN
C Grid Y ON
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CYOPT(i)(7:7) = 'G'
END DO
ELSE
CYOPT(icwin)(7:7) = 'G'
END IF
ELSE IF ( ctok(1:2).EQ.'OF') THEN
C Grid Y OFf
IF(idoall.NE.0) THEN
DO i=1,MXWIN
CYOPT(i)(7:7) = ' '
END DO
ELSE
CYOPT(icwin)(7:7) = ' '
END IF
END IF
END IF
ELSE
GOTO 590
END IF
GOTO 240
END IF
C---
C- HElp --------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'HE' .OR. ctok(1:1).EQ.'?') THEN
CALL GTREST(ctmp,ltmp)
IF(IOPEN.LT.0) CALL PLTTER('A')
ctmp(ltmp+1:) = ' '
CALL F_IHF(CHLIB, CTMP)
C---
C- Hardcopy ----------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'H') THEN
CPSAV = cpfile
CALL GTCHAR(ctok,ltok)
IF(ctok(1:1).EQ.'?') THEN
WRITE(*,*) 'Current hardcopy device is: ',
: CHARD(:LENACT(CHARD))
GOTO 100
END IF
IF(ltok.GT.0) CHARD = ctok(:ltok)
CALL PGEND
IF(IOPEN.LT.0) CALL PLTTER('A')
IOPEN = 0
cpfile = CHARD
QHARD = .TRUE.
ICLEAR = 0
GOTO 610
C---
ELSE IF ( ctok(1:1).EQ.'I' ) THEN
C---
IF ( ctok(1:3).EQ.'IMA' ) THEN
C- IMAge -------------------------------------------------------------
CALL GTCHAR(ctok,ltok)
IF ( ISNUM(ctok,ltok).NE.0 ) THEN
C IMAge # to change the currently active contour/image group.
itmp = FPNUM(ctok, ltok, Ier)
IF ( itmp.LE.0 .OR. itmp.GT.MX2D ) THEN
WRITE(*,*) 'Image number must be in the range 1 to',
: MX2D
GOTO 100
END IF
CALL PLTXCC(Yray, 1, itmp, xt, ndim, iyoff)
IF ( ndim.EQ.1 ) THEN
WRITE(*,121) itmp
GOTO 100
END IF
ic2dg = itmp
CALL GTCHAR(ctok,ltok)
END IF
IF ( ic2dg.EQ.0 ) THEN
C User has failed to define a 2D subarray. Overwrite the first group
C with the largest possible 2D array.
ic2dg = 1
isuba(1,ic2dg) = isuba(1,0)
isuba(2,ic2dg) = isuba(2,0)
isuba(3,ic2dg) = isuba(3,0)
isuba(4,ic2dg) = isuba(4,0)
igrpos(1,ic2dg) = IOFSET(isuba(2,0), Iery, Nvec, Mxrow) +
& isuba(1,0) - 1
igrpos(2,ic2dg) = (isuba(3,0)-isuba(1,0)+1)*
& (isuba(4,0)-isuba(2,0)+1)
igrpos(3,ic2dg) = isuba(2,0)
ispecg(ic2dg) = 3
CALL PLTXCN(ic2dg, 2, isuba(3,0)-isuba(1,0)+1)
CALL PLTXCL(ic2dg, 1, NO, NO)
CALL PLTXCL(ic2dg, 2, NO, NO)
imnmx = -1
END IF
ioff = 0
C
C This is the main loop for parsing the image command. NOTE, it
C is important that the next argument is parsed, before jumping back
C here, otherwise an infinite loop results.
245 CONTINUE
IF(ltok.EQ.0) THEN
C No more sub-commands.
IF ( ioff.EQ.0 ) THEN
C Activate the selected window.
image(ic2dg) = 1
IF ( ipwin(ic2dg).LE.0 ) ipwin(ic2dg) = icwin
END IF
CALL ACTWIN(ipwin, ngroup, MXWIN, iactw)
GOTO 100
END IF
CALL UPC(ctok(:ltok))
IF(ctok(1:1).EQ.'H') THEN
C IMA Histo Not currently supported!
itfun(ic2dg) = -1
ELSE IF(ctok(1:2).EQ.'LI') THEN
C IMA LIn
itfun(ic2dg) = 0
ELSE IF(ctok(1:2).EQ.'LO') THEN
C IMA LOg
itfun(ic2dg) = 1
ELSE IF(ctok(1:2).EQ.'SQ') THEN
C IMA SQrt
itfun(ic2dg) = 2
ELSE IF(ctok(1:2).EQ.'MA') THEN
C IMA MAx #
CALL GTREAL(zscale(2,ic2dg), Ier)
ELSE IF(ctok(1:2).EQ.'MI') THEN
C IMA MIn #
CALL GTREAL(zscale(1,ic2dg), Ier)
ELSE IF(ctok(1:2).EQ.'RO') THEN
C IMA ROt #
CALL GTREAL(rota(ic2dg), Ier)
ELSE IF(ctok(1:2).EQ.'CB') THEN
C IMAge CBar ON|OFF (turn color bar on or off)
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok)
IF(ctok(1:2).EQ.'OF') THEN
icbar(ic2dg) = 0
ELSE
icbar(ic2dg) = 1
END IF
ELSE IF(ctok(1:1).EQ.'C') THEN
C IMAge CCT (change color table)
CALL GTCHAR(ctmp, ltmp)
IF ( ctmp(ltmp:ltmp).EQ.'?' ) THEN
CALL PLTCCT(ctmp, ltmp)
ELSE
cctnam(ic2dg) = ctmp
lctnam(ic2dg) = ltmp
END IF
ELSE IF(ctok(1:2).EQ.'OF') THEN
C IMAge OFf
ioff = 1
image(ic2dg) = 0
IF ( icol(ic2dg).LE.0 .AND. icont(ic2dg).LE.0 )
& ipwin(ic2dg) = -ABS(ipwin(ic2dg))
ELSE IF(ctok(1:2).EQ.'ON') THEN
C IMAge ON (since most of the work upon exit, this is mostly a placeholder).
image(ic2dg) = 1
ELSE
WRITE(*,591) ctok(:ltok)
END IF
CALL GTCHAR(ctok,ltok)
GOTO 245
ELSE IF ( ctok(1:3).EQ.'IMO' ) THEN
C- Integrate model ---------------------------------------------------
IF(nterm(ICMOD).LE.0) THEN
WRITE(*,*) 'No model defined.'
GOTO 100
END IF
XL = pmin(1)
CALL GTREAL(XL,Ier)
XH = pmax(1)
CALL GTREAL(XH,Ier)
CALL GTINT(nxstep,Ier)
IF(nxstep.LE.1) nxstep = 200
XDEL = (XH-XL)/(nxstep-1.)
C
CALL PLTXCC(Yray, 1, ifitg(icmod), xt, ndim, iyoff)
IF ( ndim.EQ.1 ) THEN
yl = 0.0
yh = 0.0
nystep = 1
ydel = 1.0
ELSE
yl = pmin(2)
CALL GTREAL(yl,Ier)
yh = pmax(2)
CALL GTREAL(yh,Ier)
CALL GTINT(nystep,Ier)
IF(nystep.LE.1) nystep = 200
ydel = (yh-yl)/(nystep-1.)
END IF
C
dsum = 0.0d0
DO iystep=1, nystep
xt(2) = yl + (iystep-1)*ydel
DO i = 1,nxstep
XT(1) = XL+(i-1.)*XDEL
dsum = dsum+XDEL*ydel*
: FNFIT(XT,ICOMP(1,ICMOD),PVAL(1,ICMOD),nterm(ICMOD))
END DO
END DO
IF ( ndim.EQ.1 ) THEN
WRITE(*,251) XL,XH,dsum
251 FORMAT(' Model from ',1PG12.5,' to ',G12.5,' is ',G11.5)
ELSE
WRITE(*,261) xl,xh,yl,yh,dsum
261 FORMAT(' Model from ',1PG12.5,' to ',G12.5,/,
& ' and Y from ',1PG12.5,' to ',G12.5,' is ',G11.5)
END IF
ELSE
C Info command
ctok = ' '
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'?') THEN
WRITE(*,*) 'Possible sub-commands are:'
WRITE(*,*) 'All, Call, Groups, Scales, Windows'
GOTO 100
END IF
IF(ltok.EQ.0) THEN
ctok = 'S'
ltok = 1
END IF
IF(ctok(1:1).EQ.'C' .OR. ctok(1:1).EQ.'A') THEN
C Info Call
WRITE(*,*)
WRITE(*,*) 'Calling sequence:'
itmp = Nvec
DO I = 1,Nvec
IF(Iery(I).GT.0) itmp = itmp+Iery(I)
END DO
WRITE(*,281) Mxrow, Npts, itmp, Nvec
281 FORMAT(' Max num of rows = ',I9/
: ' Num of points = ',I7,', Num of columns = ',I5,
: ', Num of vectors = ',I5)
WRITE(*,*)
WRITE(*,*) 'Ncmd=',Ncmd,', Cmd='
DO I = 1,Ncmd
ltmp = LENACT(Cmd(I))
WRITE(*,*) Cmd(I)(:ltmp)
END DO
END IF
IF(ctok(1:1).EQ.'G' .OR. ctok(1:1).EQ.'A') THEN
C Info Groups
WRITE(*,*)
WRITE(*,*) 'Groups:'
WRITE(*,*) 'Grp, icol, Iery, ipyer, '//
: 'line, lsty, MARK, PMAR, SZMAR, FLIM, ipmod'
DO ig=1, ngroup
IF ( igrpos(1,ig).GE.0 ) THEN
lery = Iery(igrpos(3,ig))
WRITE(*,291) ig,icol(ig),lery,ipyer(ig),line(ig),
: lsty(ig),imark(ig),ipmark(ig),
: szmark(ig),flimit(ig),ipmod(ig)
291 FORMAT(I3,I6,I6,I7,I7,3I6,F7.1,F6.1,I6)
END IF
END DO
END IF
IF(ctok(1:1).EQ.'I' .OR. ctok(1:1).EQ.'A') THEN
C Info Internals
WRITE(*,*)
WRITE(*,*) 'Internals:'
WRITE(*,*) 'Grp,ipwin, igrpos(1), igrpos(2), igrpos(3)'
DO ig=1, ngroup
IF ( igrpos(1,ig).GE.0 ) THEN
WRITE(*,351) ig,ipwin(ig),
: igrpos(1,ig),igrpos(2,ig),igrpos(3,ig)
351 FORMAT(I3,I6,3I10)
END IF
END DO
END IF
IF(ctok(1:1).EQ.'S' .OR. ctok(1:1).EQ.'A') THEN
IF ( ctok(2:2).EQ.'U' ) THEN
WRITE(*,*)
WRITE(*,*) 'Subarrays:'
WRITE(*,*) 'Grp Icont Image'
DO ig=1,MX2D
WRITE(*,311) ig,icont(ig),image(ig)
311 FORMAT(I3,I6,I6)
END DO
ELSE
C Info Scales
CALL PTBUF(' ', 1)
CALL PTBUF('Scales:',-1)
CALL PTBUF('Grp Wind Label XData Min'//
& ' XData Max YData Min YData Max',-1)
DO igroup = 1,ngroup
IF ( igrpos(1,igroup).GE.0 ) THEN
WRITE(ctmp,321) igroup,ipwin(igroup),
: cglab(igroup),
: xymnmx(1,igroup),xymnmx(3,igroup),
& xymnmx(2,igroup),xymnmx(4,igroup)
321 FORMAT(I3,I6,2X,A10,1P,2(' :',G11.4,', ',G11.4))
CALL PTBUF(ctmp, -1)
END IF
END DO
END IF
END IF
IF(ctok(1:1).EQ.'W' .OR. ctok(1:1).EQ.'A') THEN
C Info Windows
WRITE(*,*)
WRITE(*,*) 'Windows:'
WRITE(*,*) 'Win, logx, logy, gridx, gridy,'//
& ' nsubx, nsuby, iwadj'
DO i=1,MXWIN
IF ( iactw(i).NE.0 ) THEN
WRITE(*,331) i,LOGX(i),LOGY(i),gridx(i),gridy(i),
& NSUBX(i), NSUBY(i), IWADJ(i)
331 FORMAT(I3,I6,I6,2F9.2,I7,I7,I7)
END IF
END DO
END IF
END IF
C---
C- Label -------------------------------------------------------------
ELSE IF ( ctok(1:2).EQ.'LA' ) THEN
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF ( ctok(1:2).EQ.'OF' ) THEN
C LAbel OFf
IPLAB = IAND(IPLAB,-2)
ELSE IF ( ctok(1:2).EQ.'ON' ) THEN
C LAbel ON
IPLAB = IOR(IPLAB,1)
ELSE IF ( ctok(1:2).EQ.'NX' ) THEN
C LAbel NX [OF|ON]
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok)
IF(ctok(1:2).EQ.'OF') THEN
ION = 0
ELSE
ION = 1
END IF
CALL GTPEEK(ctmp, ltmp)
IF ( ltmp.EQ.0 ) THEN
IF ( ION.EQ.0 ) THEN
CXOPT(icwin)(5:5) = ' '
ELSE
CXOPT(icwin)(5:5) = 'N'
END IF
ELSE
340 itmp = 0
CALL GTINT(itmp, Ier)
IF(1.LE.itmp .AND. itmp.LE.MXWIN) THEN
IF(ION.EQ.0) THEN
CXOPT(itmp)(5:5) = ' '
ELSE
CXOPT(itmp)(5:5) = 'N'
END IF
GOTO 340
END IF
GOTO 100
END IF
ELSE IF ( ctok(1:2).EQ.'NY' ) THEN
C LAbel NY [OF|ON]
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok)
IF ( ctok(1:2).EQ.'OF' ) THEN
ION = 0
ELSE
ION = 1
END IF
CALL GTPEEK(ctmp, ltmp)
IF(ltmp.EQ.0) THEN
IF(ION.EQ.0) THEN
CYOPT(icwin)(5:5) = ' '
ELSE
CYOPT(icwin)(5:5) = 'N'
END IF
ELSE
350 itmp = 0
CALL GTINT(itmp, Ier)
IF(1.LE.itmp .AND. itmp.LE.MXWIN) THEN
IF(ION.EQ.0) THEN
CYOPT(itmp)(5:5) = ' '
ELSE
CYOPT(itmp)(5:5) = 'N'
END IF
GOTO 350
END IF
GOTO 100
END IF
ELSE IF(ctok(1:2).EQ.'PA') THEN
C LAbel PArameter [ON|OF]
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:2).EQ.'OF') THEN
IPLAB = IAND(IPLAB,-3)
ELSE IF(ctok(1:2).EQ.'ON') THEN
IPLAB = IOR(IPLAB,2)
ELSE
GOTO 590
END IF
ELSE IF(ctok(1:2).EQ.'PO') THEN
C LAbel POsition
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'Y') THEN
CALL GTREAL(PYLAB, Ier)
GOTO 100
END IF
GOTO 590
ELSE IF(ctok(1:2).EQ.'OT') THEN
C LAbel OT
CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(COTLAB(icwin),ltmp)
ELSE
CALL GTREST(COTLAB(icwin),ltmp)
END IF
ELSE IF(ctok(1:2).EQ.'OX') THEN
C LAbel OX
CALL GTPEEK(ctmp,ltmp)
IF ( laswin.NE.0 ) THEN
itmp = laswin
ELSE
itmp = icwin
END IF
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(COXLAB(itmp),ltmp)
ELSE
CALL GTREST(COXLAB(itmp),ltmp)
END IF
ELSE IF(ctok(1:2).EQ.'OY') THEN
C LAbel OY
IF(ltok.GT.2) THEN
itmp = FPNUM(ctok(3:ltok),ltok-2,Ier)
iwnum = MAX(1,MIN(itmp,MXWIN))
ELSE
iwnum = icwin
END IF
CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(COYLAB(iwnum),ltmp)
ELSE
CALL GTREST(COYLAB(iwnum),ltmp)
END IF
ELSE IF(ctok(1:1).EQ.'R') THEN
C LAbel Rotate
IF(CYOPT(1)(8:8).EQ.'V') THEN
DO iwnum = 1,MXWIN
CYOPT(iwnum)(8:8) = ' '
END DO
ELSE
DO iwnum = 1,MXWIN
CYOPT(iwnum)(8:8) = 'V'
END DO
END IF
ELSE IF(ctok(1:1).EQ.'F') THEN
C LAbel File
CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(CFNAM(icwin),ltmp)
ELSE
CALL GTREST(CFNAM(icwin),ltmp)
END IF
ELSE IF(ctok(1:1).EQ.'T') THEN
C LAbel Top
IF(ltok.GT.2) THEN
itmp = FPNUM(ctok(3:ltok),ltok-2,Ier)
iwnum = MAX(1,MIN(itmp,MXWIN))
ELSE
iwnum = icwin
END IF
CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(CTLAB(iwnum),ltmp)
ELSE
CALL GTREST(CTLAB(iwnum),ltmp)
END IF
ELSE IF(ctok(1:1).EQ.'B' .OR. ctok(1:1).EQ.'X') THEN
C LAbel X (Bottom)
CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(ctok,ltok)
ELSE
CALL GTREST(ctok,ltok)
END IF
IF ( laswin.NE.0 ) THEN
CXLAB(laswin) = ctok
ELSE
CXLAB(icwin) = ctok
END IF
ELSE IF(ctok(1:1).EQ.'L' .OR.
: (ltok.EQ.1 .AND. ctok(1:1).EQ.'Y')) THEN
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(CYLAB(icwin),ltmp)
ELSE
CALL GTREST(CYLAB(icwin),ltmp)
END IF
ELSE IF(ctok(1:1).EQ.'G' .OR. ctok(1:1).EQ.'Y') THEN
IF(ltok.GT.1) THEN
igroup = FPNUM(ctok(2:ltok),ltok-1,Ier)
igroup = MAX(1,MIN(igroup,MXGRP-MXMOD))
ELSE
igroup = icwin
END IF
CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(cglab(igroup),ltmp)
ELSE
CALL GTREST(cglab(igroup),ltmp)
END IF
ELSE IF(ISNUM(ctok,ltok).NE.0) THEN
C LAbel #
iclab = FPNUM(ctok,ltok,Ier)
IF(iclab.LE.0 .OR. iclab.GT.MXLAB) GOTO 590
360 CALL GTPEEK(ctmp,ltmp)
IF(ctmp(1:1).EQ.' ') GOTO 100
CALL UPC(ctmp)
IF(ctmp(1:2).EQ.'TE') THEN
C Skip the command
CALL GTCHAR(ctmp,itmp)
C but get everything else on line
CALL GTREST(CLABEL(iclab),itmp)
IF(itmp.LE.0) THEN
ILABEL(1,iclab) = 0
ELSE IF(ILABEL(1,iclab).EQ.0) THEN
ILABEL(1,iclab) = icwin
END IF
ELSE IF(ctmp(1:1).EQ.'"') THEN
CALL GTCHAR(CLABEL(iclab),itmp)
IF(itmp.LE.0) THEN
ILABEL(1,iclab) = 0
ELSE IF(ILABEL(1,iclab).EQ.0) THEN
ILABEL(1,iclab) = icwin
END IF
ELSE
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:2).EQ.'CE') THEN
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'T') THEN
ILABEL(3,iclab) = 1
ELSE IF(ctok(1:1).EQ.'C') THEN
ILABEL(3,iclab) = 2
ELSE IF(ctok(1:1).EQ.'H') THEN
ILABEL(3,iclab) = 3
ELSE IF(ctok(1:2).EQ.'BA') THEN
ILABEL(3,iclab) = 4
ELSE IF(ctok(1:2).EQ.'BO') THEN
ILABEL(3,iclab) = 5
ELSE
GOTO 590
END IF
ELSE IF(ctok(1:2).EQ.'CO') THEN
CALL GTINT(ILABEL(4,iclab),Ier)
ELSE IF(ctok(1:2).EQ.'CS') THEN
FLABEL(4,iclab) = 1.0
CALL GTREAL(FLABEL(4,iclab),Ier)
ELSE IF(ctok(1:1).EQ.'J') THEN
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'C') THEN
ILABEL(2,iclab) = 2
ELSE IF(ctok(1:1).EQ.'L') THEN
ILABEL(2,iclab) = 1
ELSE IF(ctok(1:1).EQ.'R') THEN
ILABEL(2,iclab) = 3
ELSE
GOTO 590
END IF
ELSE IF(ctok(1:2).EQ.'LS') THEN
CALL GTINT(ILABEL(5,iclab),Ier)
ELSE IF(ctok(1:1).EQ.'L') THEN
ilabel(7,iclab) = 0
CALL GTCHAR(ctok,ltok)
IF(ISNUM(ctok,ltok).EQ.0) THEN
ILABEL(2,iclab) = 2
ILABEL(3,iclab) = 3
FLABEL(6,iclab) = 0.
ELSE
FLABEL(5,iclab) = FPNUM(ctok,ltok,Ier)
CA = COS(FLABEL(5,iclab)/RTD)
SA = SIN(FLABEL(5,iclab)/RTD)
IF(CA.GT..707) THEN
ILABEL(2,iclab) = 1
ELSE IF(CA.GT.-.707) THEN
ILABEL(2,iclab) = 2
ELSE
ILABEL(2,iclab) = 3
END IF
IF(SA.GT..707) THEN
ILABEL(3,iclab) = 5
ELSE IF(SA.GT.-.707) THEN
ILABEL(3,iclab) = 3
ELSE
ILABEL(3,iclab) = 1
END IF
C- Get optional length.
FLABEL(6,iclab) = .08
CALL GTPEEK(ctmp,ltmp)
IF(ISNUM(ctmp,ltmp).NE.0) THEN
CALL GTREAL(FLABEL(6,iclab),Ier)
END IF
END IF
ELSE IF(ctok(1:2).EQ.'MS') THEN
CALL GTREAL(FLABEL(7,iclab), Ier)
FLABEL(7,iclab) = MAX(0.,MIN(FLABEL(7,iclab),5.))
ELSE IF(ctok(1:1).EQ.'M') THEN
ILABEL(6,iclab) = -1
CALL GTINT(ILABEL(6,iclab),Ier)
IF(ILABEL(6,iclab).LT.0) THEN
ILABEL(2,iclab) = 2
ELSE
ILABEL(2,iclab) = 1
END IF
ELSE IF(ctok(1:1).EQ.'P') THEN
CALL GTPEEK(ctmp,ltmp)
CALL UPC(ctmp)
ILABEL(1,iclab) = icwin
IF(ctmp(1:1).EQ.'C') THEN
CLAbel # Pos C
CALL GTCHAR(ctmp,ltmp)
CALL PLTCUR(WINLOC, BOXVP, XYSCAL, MXWIN,
: LOGX, LOGY, iactw, iwadj, iwnum,
: VIEWX, VIEWY, WINX, WINY, ctmp)
FLABEL(1,iclab) = WINX
FLABEL(2,iclab) = WINY
ELSE
CALL GTPEEK(ctmp,ltmp)
C Special case trap for a real number entered as #e... where # is a single integer
C because GTPEEK only returns the first two characters of the token and ISNUM
C checks for a number by checking that the first and last characters are integers.
IF(ISNUM(ctmp, ltmp).EQ.0
& .AND. ctmp(2:2).NE.'e' .AND. ctmp(2:2).NE.'E'
& ) THEN
CALL PTBUF('Position expects two numbers, got "'//
& ctmp(:ltmp)//'".',-1)
CALL GTCHAR(ctmp,ltmp)
GOTO 360
END IF
CALL GTREAL(FLABEL(1,iclab),Ier)
CALL GTREAL(FLABEL(2,iclab),Ier)
END IF
ELSE IF(ctok(1:1).EQ.'R') THEN
CALL GTREAL(FLABEL(3,iclab),Ier)
ELSE IF(ctok(1:1).EQ.'T') THEN
ilabel(7,iclab) = 1
CALL GTREAL(FLABEL(5,iclab),Ier)
CALL GTREAL(FLABEL(6,iclab),Ier)
ELSE IF(ctok(1:1).EQ.'V') THEN
CALL GTPEEK(ctmp,ltmp)
CALL UPC(ctmp)
ILABEL(1,iclab) = -1
IF(ctmp(1:1).EQ.'C') THEN
C- Read cursor (flush current token)
CALL GTCHAR(ctmp,ltmp)
CALL PLTCUR(WINLOC, BOXVP, XYSCAL, MXWIN,
: LOGX, LOGY, iactw, iwadj, iwnum,
: VIEWX, VIEWY, WINX, WINY, ctmp)
FLABEL(1,iclab) = VIEWX
FLABEL(2,iclab) = VIEWY
ELSE
CALL GTREAL(FLABEL(1,iclab),Ier)
CALL GTREAL(FLABEL(2,iclab),Ier)
END IF
ELSE
CALL PTBUF('Bad sub-command: "'//ctok(:ltok)//'"',-1)
END IF
END IF
GOTO 360
ELSE
GOTO 590
END IF
C---
C- L -----------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'L') THEN
IF(ctok(1:3).EQ.'LOC') THEN
C- LOCation ----------------------------------------------------------
DO I = 1,4
CALL GTREAL(WINLOC(I,icwin), Ier)
END DO
ELSE IF(ctok(1:2).EQ.'LI') THEN
C- line --------------------------------------------------------------
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'S') THEN
C line Step
itmp = -1
ELSE IF(ctok(1:2).EQ.'ON') THEN
C line ON
itmp = +1
ELSE IF(ctok(1:2).EQ.'OF') THEN
C line OFF
itmp = 0
ELSE IF(ISNUM(ctok,ltok).NE.0) THEN
C line #
itmp = FPNUM(ctok, ltok, Ier)
IF(ABS(itmp).LE.1) GOTO 590
CALL GTPEEK(ctok,ltok)
ELSE
GOTO 590
END IF
C get next token.
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ltok.GE.2 .AND. ctok(1:2).EQ.'ON') THEN
C Skip optional ON, as in line Step ON..., or line # ON...
CALL GTCHAR(ctok,ltok)
END IF
370 CALL IRANGE(ctok,ltok,1,MXGRP-MXMOD,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXGRP-MXMOD))
IHI = MAX(1,MIN(IHI,MXGRP-MXMOD))
DO ig= ILO,IHI
line(ig) = itmp
END DO
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) GOTO 370
ELSE IF(ctok(1:2).EQ.'LO') THEN
C- LOg ---------------------------------------------------------------
CALL PLOGER(ctok, ltok, idoall, icwin, MXWIN,
: CXOPT, LOGX, CYOPT, LOGY, Ier)
IF(Ier.NE.0) GOTO 590
ELSE IF(ctok(1:2).EQ.'LS') THEN
C- LS (line Style) ---------------------------------------------------
CALL GTCHAR(ctok,ltok)
IF ( ctok(1:1).EQ.'?' ) THEN
CALL PLTSLS(-1)
GOTO 100
END IF
new = 1
IF ( ltok.GT.0 ) new = FPNUM(ctok,ltok,Ier)
CALL GTPEEK(ctok,ltok)
CALL UPC(ctok)
IF ( ctok(1:1).EQ.'O' ) THEN
C Skip optional ON/OFf.
CALL GTCHAR(ctok,ltok)
END IF
C LS # [ON]
380 CALL GTCHAR(ctok, ltok)
IF(ltok.GT.0) THEN
CALL UPC(ctok)
IF(ctok(1:1).EQ.'G') THEN
IGLS = new
ELSE IF(ctok(1:1).EQ.'M') THEN
lsty(MXGRP-MXMOD+ICMOD) = new
ELSE
CALL IRANGE(ctok,ltok,1,MXGRP-MXMOD,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXGRP-MXMOD))
IHI = MAX(1,MIN(IHI,MXGRP-MXMOD))
DO I = ILO, IHI
lsty(I) = new
END DO
END IF
GOTO 380
END IF
C---
C- LW (line Width) ---------------------------------------------------
ELSE IF(ctok(1:2).EQ.'LW') THEN
TMP = 0.
CALL GTREAL(TMP,Ier)
IF(TMP.LT.0. .AND. 15.LT.TMP) THEN
WRITE(*,*) 'LW not changed, must be in range of 1 to 15.'
GOTO 100
END IF
CALL GTPEEK(ctok,ltok)
IF(ltok.EQ.0) THEN
WIDTH = TMP
ELSE
CALL UPC(ctok)
IF(ctok(1:1).EQ.'O') THEN
C Skip optional ON/OFf.
CALL GTCHAR(ctok,ltok)
END IF
C LW # [ON] #
390 CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) THEN
CALL UPC(ctok)
IF(ctok(1:1).EQ.'M') THEN
widlin(MXGRP-MXMOD+ICMOD) = TMP
ELSE
CALL IRANGE(ctok,ltok,1,MXGRP-MXMOD,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXGRP-MXMOD))
IHI = MAX(1,MIN(IHI,MXGRP-MXMOD))
DO I = ILO, IHI
widlin(I) = TMP
END DO
END IF
GOTO 390
END IF
END IF
END IF
C---
C- M -----------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'M') THEN
IF(ctok(1:2).EQ.'MA') THEN
C- MArker ------------------------------------------------------------
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
C- First get the marker type.
IF(ISNUM(ctok,ltok).NE.0) THEN
RMARK = FPNUM(ctok,ltok,Ier)
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
ELSE IF(ctok(1:1).EQ.'S') THEN
C MArker Size
CALL GTREAL(TMP,Ier)
TMP = MAX(0.,MIN(TMP,5.))
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
ILO = 1
IHI = ngroup
IF(ltok.GE.2 .AND. ctok(1:2).EQ.'ON') THEN
CALL GTINT(ILO, Ier)
IHI = ILO
CALL GTINT(IHI, Ier)
END IF
DO ig = ILO,IHI
szmark(ig) = TMP
END DO
GOTO 100
ELSE IF(ctok(1:1).EQ.'?') THEN
IF(IOPEN.NE.0) THEN
CALL PLTMAR
ELSE
WRITE(*,*) 'No graphics device available.'
END IF
GOTO 100
ELSE
RMARK = NO
END IF
C- Now get ON/OFf flag.
IF(ctok(1:2).EQ.'ON') THEN
itmp = 1
ELSE IF(ctok(1:2).EQ.'OF') THEN
itmp = 0
ELSE
GOTO 590
END IF
C- Finally the vectors to mark
CALL GTCHAR(ctok,ltok)
C---
400 CONTINUE
CALL IRANGE(ctok,ltok,1,MXGRP-MXMOD,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXGRP-MXMOD))
IHI = MAX(1,MIN(IHI,MXGRP-MXMOD))
DO ig= ILO,IHI
ipmark(ig) = itmp
IF(RMARK.NE.NO) imark(ig) = RMARK
END DO
CALL GTCHAR(ctok,ltok)
IF(ltok.GT.0) GOTO 400
C---
C- MMaster -----------------------------------------------------------
ELSE IF ( ctok(1:2).EQ.'MM' ) THEN
C MMaster iwin X|Y|XY wlist
iwnum = 0
CALL GTINT(iwnum, ier)
IF ( iwnum.LE.0 .OR. MXWIN.LT.iwnum ) THEN
WRITE(*,401) MXWIN
401 FORMAT(' Window number must be in range 1 to ',I5,'.')
GOTO 100
END IF
ctok = ' '
CALL GTCHAR(ctok, ltok)
CALL UPC(ctok)
IF ( ctok(1:1).EQ.'O' ) THEN
DO i=1,MXWIN
IF ( imaster(1,i).EQ.iwnum ) imaster(1,i) = 0
IF ( imaster(2,i).EQ.iwnum ) imaster(2,i) = 0
END DO
imaster(1,iwnum) = 0
imaster(2,iwnum) = 0
GOTO 100
END IF
C- Find the list of slave windows
410 CALL GTCHAR(cscr1, lscr1)
IF ( lscr1.LE.0 ) THEN
IF ( INDEX(ctok,'X').GT.0 ) THEN
imaster(1, iwnum) = -1
END IF
IF ( INDEX(ctok,'Y').GT.0 ) THEN
imaster(2, iwnum) = -1
END IF
ELSE
CALL IRANGE(cscr1,lscr1,1,MXWIN,ILO,IHI,Ier)
ILO = MAX(1,MIN(ILO,MXWIN))
IHI = MAX(1,MIN(IHI,MXWIN))
DO I = ILO,IHI
IF ( i.NE.iwnum ) THEN
IF ( INDEX(ctok,'X').GT.0 ) THEN
imaster(1, i) = iwnum
xyscal(1,i) = xyscal(1,iwnum)
xyscal(3,i) = xyscal(3,iwnum)
END IF
IF ( INDEX(ctok,'Y').GT.0 ) THEN
imaster(2, i) = iwnum
xyscal(2,i) = xyscal(2,iwnum)
xyscal(4,i) = xyscal(4,iwnum)
END IF
END IF
END DO
GOTO 410
END IF
C---
C- MOdel -------------------------------------------------------------
ELSE IF(ctok(1:2).EQ.'MO') THEN
IF ( IOPEN.LT.0 ) CALL PLTTER('A')
CALL GTPEEK(ctok,ltok)
IF ( ISNUM(ctok,ltok).NE.0 ) THEN
CALL GTINT(ICMOD, Ier)
ICMOD = MIN(MAX(1,ICMOD),MXMOD)
CALL GTPEEK(ctok, ltok)
IF(ltok.LE.0) GOTO 100
END IF
C
C Figure out MIN/MAX in both X and Y for window containing fit group.
CALL FITVIS(ipwin, ngroup, ifitg(icmod))
pmin(1) = MIN(xyscal(1,ipwin(ifitg(icmod))),
& XYSCAL(3,ipwin(ifitg(icmod))))
pmax(1) = MAX(xyscal(1,ipwin(ifitg(icmod))),
& XYSCAL(3,ipwin(ifitg(icmod))))
pmin(2) = MIN(xyscal(2,ipwin(ifitg(icmod))),
& XYSCAL(4,ipwin(ifitg(icmod))))
pmax(2) = MAX(xyscal(2,ipwin(ifitg(icmod))),
& XYSCAL(4,ipwin(ifitg(icmod))))
C
C Pass subcommend to MODEL routine
CALL GTREST(ctok,ltok)
ctmp = 'MO '//ctok
CALL MODEL(ctmp,pmin,pmax,MXPAR,Cmd,Ncmd,Icmd,
: ICOMP(1,ICMOD),PVAL(1,ICMOD),PLIM(1,1,ICMOD),nterm(ICMOD))
IF ( nterm(ICMOD).GT.0 ) THEN
ipwin(MXGRP-MXMOD+icmod) = ipwin(ifitg(icmod))
ipmod(MXGRP-MXMOD+icmod) = icmod
igrpos(1, MXGRP-MXMOD+icmod) = igrpos(1, ifitg(icmod))
igrpos(2, MXGRP-MXMOD+icmod) = igrpos(2, ifitg(icmod))
igrpos(3, MXGRP-MXMOD+icmod) = igrpos(3, ifitg(icmod))
ipyer(MXGRP-MXMOD+icmod) = ipyer(ifitg(icmod))
newmod = icmod
END IF
END IF
C---
C- Newpar ------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'N') THEN
C- If NO is combined with a operation (* / + -) then it will
C- be treated as a command. Warn user by checking here.
IF(ltok.GT.1 .AND. ctok(2:2).NE.'E') GOTO 590
IF(nterm(ICMOD).LE.0) THEN
WRITE(*,411)
411 FORMAT(' No model defined.')
ELSE
IF(IOPEN.LT.0) CALL PLTTER('A')
CALL GTREST(ctok,ltok)
ctmp = 'NE '//ctok
CALL MODEL(ctmp,pmin,pmax,MXPAR,Cmd,Ncmd,Icmd,
& ICOMP(1,ICMOD),PVAL(1,ICMOD),PLIM(1,1,ICMOD),nterm(ICMOD))
newmod = icmod
END IF
C---
C- Overlay -----------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'O') THEN
ICLEAR = 0
GOTO 610
C---
C- P -----------------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'P') THEN
IF(ctok(1:2).EQ.'PA') THEN
C- PAper -------------------------------------------------------------
CALL GTREAL(PGPAPW, Ier)
CALL GTREAL(PGPAPA, Ier)
IF ( iopen.NE.0 ) THEN
CALL PGPAP(PGPAPW/2.54,PGPAPA)
END IF
ELSE IF(ctok(1:2).EQ.'PR') THEN
C- PRompt ------------------------------------------------------------
CALL GTCHAR(CPROM,LPROM)
C- Plot --------------------------------------------------------------
ELSE
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
ICLEAR = 1
IF(ltok.LE.0 ) GOTO 610
IF(ctok(1:1).EQ.'A') THEN
QALL = .TRUE.
ELSE IF(ctok(1:1).EQ.'G') THEN
QALL = .FALSE.
ELSE IF(ctok(1:1).EQ.'O') THEN
C- Plot Overlay. Plot all groups in window 1, full screen, numeric labs
DO ig= 1,ngroup
IF ( ipwin(ig).GT.0 ) ipwin(ig) = 1
END DO
CALL ACTWIN(ipwin,ngroup,MXWIN,iactw)
WINLOC(2,1) = 0.
WINLOC(4,1) = 1.
CXOPT(1)(5:5) = 'N'
C Restore top label of top window, to be master top label
IF(icwin.NE.1 .AND. LENACT(CTLAB(icwin)).NE.0) THEN
CTLAB(1) = CTLAB(icwin)
CTLAB(icwin) = ' '
END IF
C Restore file label of top window, to be master top label
IF(icwin.NE.1 .AND. LENACT(CFNAM(icwin)).NE.0) THEN
CFNAM(1) = CFNAM(icwin)
CFNAM(icwin) = ' '
END IF
C Restore X label of bottom window, to be master X label
IF(icwin.NE.1 .AND. laswin.NE.0 ) THEN
IF ( LENACT(CXLAB(laswin)).NE.0 ) THEN
CXLAB(1) = CXLAB(laswin)
CXLAB(icwin) = ' '
END IF
END IF
icwin = 1
LASWIN = 0
ELSE IF(ctok(1:1).EQ.'V') THEN
C- Plot Vert. NVERT counts the number of active windows.
NVERT = 0
itmp = 0
C Assign one window to each group that is being plotted. For
C compatibility number the windows by the group being plotted in that
C window. Default lastwin to 1 in case there are no active windows.
laswin = 1
DO igroup = 1,MIN(ngroup,MXWIN)
IF ( ipwin(igroup).GT.0 ) THEN
IF(itmp.EQ.0) itmp = igroup
ipwin(igroup) = igroup
NVERT = NVERT+1
LASWIN = igroup
END IF
END DO
C Move top label to top label of the top window.
IF(icwin.NE.itmp .AND. LENACT(CTLAB(icwin)).NE.0) THEN
CTLAB(itmp) = CTLAB(icwin)
CTLAB(icwin) = ' '
END IF
C Move file label to top label of the top window.
IF(icwin.NE.itmp .AND. LENACT(CFNAM(icwin)).NE.0) THEN
CFNAM(itmp) = CFNAM(icwin)
CFNAM(icwin) = ' '
END IF
C Move X label to be X label of bottom window.
IF(icwin.NE.itmp .AND. LENACT(CXLAB(icwin)).NE.0) THEN
CXLAB(laswin) = CXLAB(icwin)
CXLAB(icwin) = ' '
END IF
C Generate active window list.
CALL ACTWIN(ipwin,ngroup,MXWIN,iactw)
C new current window
icwin = itmp
TMP = (BOXVP(4,1)-BOXVP(2,1))/NVERT
itmp = NVERT
DO iwnum = 1,MXWIN
IF(iactw(iwnum).GT.0) THEN
TMP1 = BOXVP(2,1)+TMP*itmp-TMP/2.
WINLOC(4,iwnum) = TMP1+1./(2.*NVERT)
WINLOC(2,iwnum) = TMP1-1./(2.*NVERT)
IF(itmp.GT.1) itmp = itmp-1
CXOPT(iwnum)(5:5) = ' '
END IF
END DO
CXOPT(LASWIN)(5:5) = 'N'
ELSE IF(ctok(1:1).EQ.'Z') THEN
C Plot Zero
CALL GTCHAR(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:2).EQ.'ON') THEN
IPZERO = 1
ELSE IF(ctok(1:2).EQ.'OF') THEN
IPZERO = 0
ELSE
GOTO 590
END IF
ELSE
GOTO 590
END IF
END IF
C---
C- Rescale -----------------------------------------------------------
ELSE IF(ctok(1:1).EQ.'R') THEN
ICLEAR = 1
CALL GTPEEK(ctok,ltok)
CALL UPC(ctok)
IF(ctok(1:1).EQ.'?') THEN
IF(IOPEN.LT.0) CALL PLTTER('A')
IF ( IGAP.EQ.0 ) THEN
WRITE(*,421) RGAP,'NoErrors'
ELSE
WRITE(*,421) RGAP,'Errors'
END IF
421 FORMAT(' Current Gap = ',F7.3,5X,A,/,'Window',3X,
: 'XLAB XMIN XMAX',9X,
: 'YLAB YMIN YMAX')
DO 440 iwnum = 1,MXWIN
IF(iactw(iwnum).LE.0) GOTO 440
ctok = CXLAB(iwnum)
IF ( LENACT(ctok).LE.0 ) THEN
IF ( ixvec.NE.0 ) ctok = cglab(ixvec)
END IF
ctmp = CYLAB(iwnum)
IF ( LENACT(ctmp).LE.0 ) THEN
igroup = IFGRP(ipwin, MXGRP-MXMOD, iwnum)
IF(igroup.EQ.0) igroup = 2
ctmp = cglab(igroup)
END IF
WRITE(*,431) iwnum,ctok,XYSCAL(1,iwnum),XYSCAL(3,iwnum),
: ctmp,XYSCAL(2,iwnum),XYSCAL(4,iwnum)
431 FORMAT(1X,I3,' : ',A10,1PG11.4,',',G11.4,' : ',
: A10,G11.4,',',G11.4)
440 CONTINUE
GOTO 100
ELSE IF(ctok(1:1).EQ.'X') THEN
C- R X
CALL GTCHAR(ctok,ltok)
iwnum = icwin
IF(ltok.GT.1) THEN
C- R X#
itmp = FPNUM(ctok(2:ltok),ltok-1,Ier)
IF(1.LE.itmp .AND. itmp.LE.MXWIN) iwnum = itmp
END IF
CALL GTPEEK(ctmp,ltmp)
CALL UPC(ctmp)
IF(ltmp.LE.0) THEN
C- R X
The current version of POW is 3.0 and it is still under active development.
POW features a very flexible developer's interface and a "friendly" end
user GUI interface. POW is a Tcl/Tk extension and can be called from
standard C or FORTRAN main programs.
fv5.5/tcltk/pow/Blinking.html 0000644 0002207 0000036 00000011022 13224715127 015066 0 ustar birby lhea
At the top of the dialog box is the name of the selected graph
followed by the number of images in the graph and the image number
currently in the foreground. The Prev and Next buttons
immediately below this information step through the images, bringing
each one to the foreground in turn. It is possible to either blink
all the images in order or in a specified sequence. The Add to
List button appends to this sequence list the image currently in
the foreground. The sequence List entry box consists of a
comma-separated list of image numbers and/or ranges (e.g.,
1-3,5,8-10,14). A pair of radio buttons determines with the sequence
list is used or all the images are blinked in order. Two checkbuttons
control whether blinking is Looped--repeated indefinitely--or
stopped after the last image is displayed, or blinked in
Reverse order. A slidebar controls the Speed at which
blinking occurs. All these controls can be
modified while images are being blinked and will take effect
immediately. To have a new list of frames take effect, though, one must
reselect the List radio button.
When the controls are set to their desired values, press the Blink
Images button to begin blinking. The button changes to Stop
Blinking.
If the selected graph is changed while the dialog box is open, press
the Reload Info button to update the dialog with the new
information.
Blink begins when the Blink Graphs button is
pressed. Blinking is always in the specified order (no reverse
option) and will repeat indefinitely until the Stop Blinking
button (same as the Blink Graphs button) is pressed.
As graphs normally don't initially overlap and will likely need to be
repositioned, the graphs in the Blink Order list can be moved from
within the dialog box. A compass labeled Shift & Align
Graphs is present in the center of the dialog box. Clicking on
the center of the compass aligns all the graphs in the list according
to the top right corner of the first graph. Clicking on any of the
arrows shifts the highlighted graphs 10 pixels in that direction.
Shift-clicking an arrow shifts the graphs 1 pixel at a time. The
graphs continue to move in these increments until the mouse button is
released or the cursor leaves the compass arrow. (Note: if an
individual graph is present several times in the Blink Order list,
each instance of it in the highlighted selection will experience the
shift.) Graphs can be repositioned with the compass while
blinking.
If graphs are added to the POW canvas while the dialog box is open,
press the Reload Info button to create a new list of Available
Graphs.
fv5.5/tcltk/pow/Color.html 0000644 0002207 0000036 00000006343 13224715127 014421 0 ustar birby lhea
POW allows some interactive manipulation of the Colortable used
to display grayscale images. POW has detailed X Colormap
handling options. There are four different
ways of dealing with colormaps. The powColormap options are
available in fv by using the "-cmap" command line argument to
fv. The different options are:
Plot the model using color index #.
Color # ON Grid
Use the color index specified by # when plotting the grid in the
currently active window.
COlor ?
Generate a list of possible color indices and their default color
representations.
3 examples
PLT> COlor OFf 1,2,3 ! Suppress plotting of groups 1, 2, and 3
PLT> COlor ON 2 ! Turn on plotting of group 2
PLT> COlor 5 ON 3 ! Use color 5 when plotting group 3
2 CONtour
CONtour [gnum] ?|COlor list|LEvel list|LStyle list|LWidth list|OFf
This command causes PLT contour a two dimensional array of data.
The first number denotes the plot group to be contoured. If you have
not defined any two dimensional plot groups, then PLT will automatically
create a group for you that consists of the largest possible chunk
of the main data array. If you omit the first number then PLT uses
the group number from the last time you used the CONtour, IMAge, DGroup
(to define a 2D array). If none of these commands were used, the
PLT will use group 1.
A contour plot does not automatically turn off the normal plotting
of the remaining plot groups, and typical arrays to be contoured may
contains lots (hundreds!) of columns the possiblity that some of
those groups will normally overwrite the contour is high. Thus you
are advised to issue a
COlor OFf 1..999
to suppress the normal ploting, unless, of course you are a PLT
wizard and want to mix the two types of plot.
If order for a contour to appear you must define a set of levels
via the LEvel subcommand.
3 example
Although this example is intended to be standalone, it will work with
the fig06.qdp file. In other words, if you use qdp to plot fig06.qdp
you can enter the following commands to get two contour plots in two
windows. You will also note that group 1 is plotted in window 2 and
group 2 in window 1. This was done purely to illustrate that it is
possible. In general you will get a lot less confused if you stick
to a simpler convention (e.g., group 1 in window 1, etc.)
Yplot OFf 1..99 ! Turn off all previous plots
DGroup 2 1 1 10 20 ! Define group 2 to be a 2D group
WIN 1 ! Define the window to use
LOC 0 0 0.5 0.5 ! Locate window in bottom left corner
YPL 2 ! Plot group 2 in window 1
CON 2 LEvels -0.5 0 0.5 ! Create contours at three levels
CON 2 LStyle 4 4 ! Use dotted lines for negative levels
CON 2 LWidth,,3 ! Make the level=0 line fatter
GAP 0.0 Nerr ! Best for contour plots
R ! Reset the scale in this window
DGroup 1 11 1 20 20 ! Define group 1
WIN 2 ! Define a second window
YPL 1 ! Plot group 1 in window 2
LOC 0.5 0.5 1.0 1.0 ! :ocate window in upper right corner
CON 1 LEvels -1.5 -0.5 0 0.5 1.5
CON 1 LWidth,,,3 ! Fatten up level=0 in this plot
CON 1 LStyle 4 4 ! Use dotted lines for negative levels
R ! Reset the scale in this window
3 hints
PGPLOT draws the line segments that make up the contour such that
one coordinate of an (x,y) pair is always at a integer pixel position,
i.e., a pixel center. This makes sense if you assume the z value
is correct at the center of the pixel and thus one is computing where
the contour level intersects the line between two pixel centers.
To correctly set the default scale for contour plot you should use:
GAp 0.0 Noerrors
R ! reset the default scale.
The GAp 0.0 ensures that there is no extra gap around the data, and
the Noerrors causes the error bars to be ignored when min/max values
are computed. This causes the default scale to be set by the pixel
centers.
It is possible to plot both a contour and an image in the same
window. If the contour and image are both from the same group
the PLT automatically plots the image first and then the contour
"on top" of the image. If the contour and image correspond to
different groups, then you should make sure the image is assigned
a lower group number. This is because PLT plots the groups in
order from the lowest to the highest.
3 Color
By default PLT plots the first contour with color index 1, the
second with color index 2, etc. (Use the PLT COlor ? command to see
the default mapping of color index into colors). The CONtour Color
sub-command can be used to override this default. Thus to plot the
first 10 levels with color index 1, you would use
CON Color 1 1 1 1 1 1 1 1 1 1
and to change just the third level to color index 3 use
CON Color,,,3
Note, you must use the CONtour LEv subcommand to define the levels
before any contours will be plotted.
3 LEvel
This subcommand is required must be used before a contour plot will
appear. The CONtour LEvel subcommand is followed by a list of numbers
that correspond to the levels to be contoured. You can define up
to 32 (set by MXLEV in PLT code) contour levels. Thus
CON LEV -20 -10 0 10 20
would define 5 levels. PLT remembers the previous levels so you
change the value for level 3 only by
CON LEV ,,,3.14159
To use fewer levels than what had been previously defined you must
use the NO data value. Thus
CON LEV,,,,no
would leave the first 3 levels unchanged and stop plotting levels above 4.
3 LStyle
By default all contours are plotted with a line style of one. (Use
the PLT "LStyle ?" command to get a list of the possible styles.)
You can use the CONtour LStyle sub-command to change this. Suppose
you wanted to use dotted lines (line style of 4) to plot negative
contours. You would do this with
CON LEV -10 -20 0 10 20
CON LS 4 4
Thus the first two contour levels would now be plotted with line
style of 2 and the remainder would use the default line style.
Note, you must use the CONtour LEv subcommand to define the levels
before any contours will be plotted.
3 LWidth
By default all contours are plotted with a line width of 1. You
can override this default using the CONtour LWidth subcommand. Thus
CON LWidth,,,3
would plot the third level with a line width of 3.
Note, you must use the CONtour LEv subcommand to define the levels
before any contours will be plotted.
3 OFf
This subcommand is use to switch off the plotting of a contour
with a plot group. This you no longer wish to see plot group 2
plotted with a contour, then you would use
CON 2 OFF
Of course, if you now want to see plot group 2 plotted as a regular
Y vs X manner, make sure you use the COlor ON command, i.e., COL ON 2.
Since group 2 is now a two dimensional array, you will now see the
entire array was was being contoured projected onto the X coordinate.
If you wish to restore group 2 to its original one dimensional form
you should use "DGrroup 2 2", i.e., define group 2 to be the second
vector in the main data array.
2 CPD
CPD [$]
Change the current plotting device. The current plot device is
released; the next plot will be produced on the new device. By default
PLT uses the plotting device specified in the PGPLOT_TYPE environment
variable. If this variable is not defined then PLT will prompt for
a plotting device at startup.
Note: "CPD" with no argument releases the current plotting device.
This is useful when plotting to a file and closing the device is
necessary to get PGPLOT properly terminate and close the file. Also
"CPD ?" will list all the devices supported.
3 examples
PLT> CPD /PS ! Output Postscript commands to a file
PLT> Plot ! Send the current plot to the file
PLT> CPD ! Close the file
2 CQuit
CQuit
Immediately clear the plot device and exit subroutine PLT.
2 CSize
CSize #
Set character size to # where # is greater than zero and less than
five (one is default).
3 example
PLT> CSize 2.0 ! Use a character size twice the default
2 Device
Device [$]
Define the plotting device. This is a synonym for the "CPD" command.
2 DGroup
DGroup gnum def
The define group command, DGroup, allows programmers and/or users
to define new plot groups. The PLT default is for each plot group
to consist of a data vector (the SKip command provides another way
to override this default). The DGroup command gives the user total
control over how the plot groups are defined.
The gnum is the group number and must be in the range 1 to MXGRP-MXMOD
(typically 60).
def is the group definition and can be either
a) A single number. The number corresponds to a vector number in
the main data array. Thus "DGroup 2 2" would define group 2 to be
the second vector, which is the default.
b) Four numbers. If you think of the main data array to be a two
dimensional array with coordinates corresponding to the row and vector
numbers, then the first two numbers define a row, vector coordinate
of one corner and the second set form the other corner. Thus
"DGroup 4 5 3 10 3" would define group 4 to be rows 5 through 10
of vector 3, and "DGroup 4 1 1 10 20" would cause group 4 to include
rows 1 through 10 and vectors 1 to 20.
c) Either the word Model or Residual. By default, PLT reserves
the high numbered groups (typically 61 to 64) to contain the model.
However if you want to plot the same model in different window than
the default you can define a new group to be that model The
"DGroup 3 Res" command would cause group 3 to contain the current
model residuals. The data min and max values are recomputed every
time the model is changed. Of course, PLT does not change the scale
unless you issue a "Rescale" command.
3 residual_example
PLT> MO 1 CO ! Define a COnstant model
23 ! Starting parameter
PLT> DGroup 2 Res ! Group 2 is the model residuals
PLT> YPL 2 ! Plot group 2 in current window
PLT> R Y ! Rescale and replot
PLT> FIT ! Fit
PLT> P ! Replot using the original scale
PLT> R Y ! Rescale using currng residual min/max values
3 examples
PLT> DGroup 2 2 ! Group 2 is vector 2 (the PLT default)
PLT> DGroup 2 1 2 10 2 ! Group 2 is rows 1 to 10 of vector 2
PLT> DGroup 2 2 1 10 99 ! Group 2 is now two dimensional, consisting
! of rows 2 through 10 and vectors 1 to 99.
PLT> Dgroup 2 Res ! Group 2 is now the model residuals.
2 Error
Error OFf [glist]
Turn off the plotting of errors for all plot groups specified in
"[glist]".
Error ON [glist]
Undo the effects of the "Error OFf" command for the specified
plot groups.
Error Sq [glist]
Set errors equal to "SQRT(value)" for the specified plot groups.
Error Dia [glist]
Draw diamond style errors on specified groups.
Error X ON|OFf [glist]
This command controls the plotting of the x-error bars. For example,
if groups 1,2, and 3 all have associated errors, then the command
sequence "Xaxis 1"; "Error X ON 2"; "Error X OFf 3", would cause the
x-errors to be plotted when group 2 is plotted but not when group 3
is plotted.
When fitting data, error bars will be used to weight the data only
if the errors are visible. Thus "Error OFf" followed by "Fit" will
produce an unweighted fit. Also, note that only the y-errors are
used to weight the data.
3 examples
PLT> Error OFf 1,2,3 ! Turn off errors for groups 1, 2, and 3
PLT> Error Dia 2 ! Plot diamond errors on plot group 2
PLT> Error ON ! Plot errors for all plot groups
PLT> SKip Sing ! Turn on the `skip' mode
PLT> Error X OFF ! Suppress plotting of errors in x-direction
2 EXit
EXit
Exit subroutine PLT.
2 Fit
Fit [#] [Iterate #]
Cause PLT to call the fitting routine to search for the best fitting
parameters for the model specified with the "MOdel" command. The
first optional number is the plot group to fit. If this number is
omitted, then "Fit" will continue to fit the previous group that you
were fitting if that plot group is still visible. For the first use
of "Fit" or if the plot group has been "COlored OFf" then "Fit" will
default to fitting the lowest numbered group which is visible. The
"LAbel PArm" command controls whether the model parameters are plotted
on the right side of the plot. Fitting continues until Delta chi^2
is less than 0.05. As a default, you will be prompted to continue
fitting every 10 iterations. If you wish to increase the number of
iterations without being prompted, then use the "Fit Iterate [#]".
Thus, "Fit I 100", would allow the program to try up to 100 iterations
before you would be prompted again.
Fit ON [#]
Cause the current model to be plotted on group #. If # is omitted,
the model will be plotted on plot group that was most recently fitted.
Fit OFf
Cause the model to no longer be plotted.
Fit Plot #
Control where the model is evaluated when it plotted. If # is
greater than zero, then the model is evaluated at # points between
the current x-scale Minimum and Maximum. If # is less than 0, then
the model is evaluated at "ABS(#)" points between the Data Min and Data
Max --- i.e., no extrapolation is allowed. If # equals 0, then the
model is evaluated at the values of the data points. (This is the
default.)
Fit Stat Chi|Ml #
Set the default fitting statistic to either chi^2 or maximum
likelihood. For example, "Fit Stat M 2" would vary the fit parameter
to minimize the likelihood function when compared with plot group 2.
3 statistics
Prior to 1998 Oct, Fit Stat ML would minimize the likelihood function:
C = 2 * SUM{ model(i) - data(i)*ln(model(i)) + ln(data(i)!) }
where data(i) is the observed number of *counts* in the i'th bin and
model(i) is the model evaluated at that location. Of course, data(i)!
is the factorial. On 1998-Oct-01, the statistic was changed to:
C = 2 * SUM{ model(i) + data(i)*[ln(data(i))-ln(model(i))-1.] }
which is the same statistic as is now used by XSPEC (the famous John
Castor "priv. comm." statistic). This differs from the likelihood
function in terms that depend only upon the data. Since the goal
is to find the minimum with respect to changes in the model
parameters, this function will have the same minimum as the likelihood
function. The advantage of this new function is that when you
get a good fit, then C ~ DOF similar to chi^2. Of course, I would
not suggest using a chi^2 table to interpret any results.
Prior to this change the "fit stat ml" would only work properly if
you were fitting raw counts. If we assume that
rate(i) +/- sigma(i) = data(i)/E +/- SQRT(data(i))/E
where E is typically the exposure (area*time). Then it is easy to
show that:
E = rate(i)/(sigma(i)^2)
(It is straightforward to handle the special case where data(i)=0.)
Using this expression, the PLT version of CURFIT now scales the rate
back into raw counts, and hence it is now possible to fit rates using
"stat ml". If you accidently used "stat ml" with the old version,
then don't worry, the main difference is the estimated parameter
uncertainties, in the old version the estimate would be way off, and
now they are approximately correct.
Finally, there is the case where the model goes to zero. There is
no problem where the data(i) is also zero as C will evaluate to zero
at that location. Formally speaking if the data<>0 then clearly there
is a background term that should be included in the model (and if
don't include the background then you really should not be fitting
points where model=0). On the other hand, if the background level
is low, for example, most of the counts are in a single gaussian shaped
feature, then it is real tempting to model this with a single gaussian
term and no background. If you tried this with the old version
then you would discover that the gaussian width would slowly increase.
This happened because it would result in fewer non-zero model bins
and this would improve the statistic.
In the new version a model floor is defined. Thus if the model
evalutates to less than the floor level, when calculating the statistic,
the floor value is used. For now the floor value used is 1.0E-6
counts/bin. Thus if your model depends on seeing one (or fewer) count
in a million bins, then this will result in a error or bias. On the
other hand this does allow you to fit a narrow gaussian, no background
and get a sensible result.
2 FNy
FNy #
Return the value of the current "MOdel" function at location #.
3 example
PLT> MOdel LINR CONS ! Define a straight line
1, LI: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
2. ! Set slope of line equal to 2
2, CO: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
3. ! Set intercept of line equal to 3
PLT> FNY 3 ! Evaluate function at x=3.0
12.0 ! The result
2 FOnt
FOnt $
Set the default to the font specified by the character string.
(Default is Simple font.)
FOnt ?
List possible fonts.
3 example
PLT> Font Roman ! Use the Roman font
2 FReeze
FReeze [plist]
Can only be used after a model has been defined. This command
causes all parameters listed in "[plist]" to be frozen, which means
the parameter value is not allowed to vary during a "Fit".
3 examples
PLT> FReeze 2 ! Freeze the value of parameter 2
PLT> FReeze 3..5 9 ! Freeze the values of parameters 3 through 5 and 9
2 GAp
GAp #
Control the size of the gap between the edge of the plot and the
data extrema, when using the default scale. The effect of the "GAp"
command can only be seen when you reset the default scale with "R",
"R X", or "R Y" (all with no arguments). The default gap is 0.025
which will leave a 2.5 percent margin around the edge. The size of
the gap in world coordinates, depends on whether the data are being
plotted on a logarithmic scale. Therefore, if you wish to use a
default, logarithmic scale, you should first issue the "LOg" and "GAp"
commands and then use the "Rescale" command to reset the default scale.
The default gap is calculated based on the minimum and maximum of
the data. If your data contains errors, then it is often useful to
include the error bars in the calculation. This can be done using
the "GAp Error" command which means the gap is calculated based on
the minimum and maximum values including a one sigma error bar on
the data. To revert to the original behavior to not include errors,
use "GAp NoError".
3 examples
PLT> GAp 0.0 ! No gap
PLT> R X ! Use default X scale
PLT> GAp 0.05 ! Reset gap, for use with Y scale
PLT> LOg Y ! Log the Y scale
PLT> R Y ! Use default Y scale
2 Grid
Grid [clist]
Control the plotting of a grid, where "[clist]" is one or more
of "ON", "OFf", "X # #", "Y # #". For "Grid ON", the major tic marks
are expanded to place a grid over the entire plot. "Grid OFf" turns
off the grid replacing the tic marks. PGPLOT automatically selects
the location of the major and minor tic marks. The "Grid" command
allows you to override this selection. For example, "Grid X 10,2"
would divide the x-axis into 10 major divisions and then divide each
major division into 2 minor divisions. Use "Grid X 0,0" to go back
to the default grid. The number -1 can be used to suppress the plotting
of tic marks. Thus, "Grid X -1 0" would only plot minor tic marks
on the x-axis and "Grid Y -1 -1" would prevent any tic marks from
being plotted on the y-axis.
IMPORTANT: PGPLOT only places major tic marks at locations where
the least significant digit of the range increments by integer amounts.
If you attempt to force PGPLOT to violate this condition, then
unexpected things may happen. For example, suppose you had used
"R Y 0 .15", in which case the range is 0.15 and the least significant
digit is 0.01. Then using "Grid Y 3,2" would place grid lines at
intervals of 0.05. However, if you had tried "Grid Y 2,2", then the
grid lines would occur at intervals of 0.075, where the last digit (5)
is not a significant digit. In this case, the plot will be incorrectly
labeled. "Grid X 1.5,2" is legal and would correctly produce labels
at intervals of 0.1. (Of course, only one label would actually be
plotted in this case.)
2 Hardcopy
Hardcopy [$]
Generate a copy of the plot using the current hardcopy specification.
In general, this makes a file that can later be printed. The default
PLT hardcopy device for the first use can be set using the PLT_HARDCOPY
logical name (on VMS systems) or environment variable (on UNIX systems).
After the first time, the "Hardcopy" command defaults to the same
device as was specified in the previous "Hardcopy" command. "Hardcopy"
produces a copy of what you would see if you reissued the "Plot" command.
This might not be an exact copy of what is currently displayed on the
graphics device.
Hardcopy ?
Display on the terminal the default hardcopy specification.
3 example
PLT> Hardcopy /PS ! Create a Postscript file
2 HElp
HElp [pcommand]
Get help on the PLT command specified by "[pcommand]".
2 IMAge
IMAge [MIN #|MAX #|OFF|CCT $|LOG|LIN|SQRT|HISTO|TOT]
This command will allow you to display your data as an image.
3 CCT
IMAge CCT $
PLT currently has 3 built in color tables. Use
PLT> IMA CCT ?
to see a list of these and a brief description. Thus if you use
"CCT 1" you will get the gray scale color where the minimum value
appears black and the maximum as white. To invert the color table
preceed the name with a minus sign (no space). Thus "CCT -1" would
give a grayscale image where the minimum is white and the max is black.
Color tables can also be defined in external ASCII files. If you have
a file called "blue.ct" then you can read this with "CCT blue".
Note, "CCT -blue" will invert the color table, hence you are advised
not to use a minus sign as the first character in the file name.
4 example
PLT> IMA CCT 2 ! Use builtin color table 2 to display images.
4 file_format
A color table file is an ASCII file consisting of a series of rows
each with 4 columns. The first column is the "normalized color
index" which must be in the range 0 to 1 and monotonically increasing.
The next 3 columns are for the red, green, and blue values and each
number must be in the range 0 to 1. Thus a minimal color table
would consist of just two rows. Here is some sample data from
a file which we will call "blue.ct"
!CI R G B
0. 0. 0. 0.
1. 0. 0. 1.
Using "CCT blue" will cause the minimum value to be plotted in black
(no color on) and the maximum value will be plotted with the blue
color full on, but red and green colors off.
How does the color table work? Suppose PGPLOT has allocated color
indices 17 to 240 for images. Assume you have set the min value is
0 and the max is 100, and you are about to display a pixel value of
40. With the linear scaling PGPLOT would plot this value with a color
index of 0.4*(240-17+1) = 90. The normalized color index is
40/(100-0+1) = 0.40. Since this color index two values in the file,
the software will do a linear interpolation for the red, green and
blue values. Using the blue.ct given above, red and green values
would both be off and the blue value would be set to 40 percent of
the maximum value.
The reason for using a normalized color index and an normalized color
intensities is to reduce the dependence on the graphics device, i.e.,
you don't need to know how many color indices the device supports
nor which ones PGPLOT have allocated to the image. Anyone who has
worked with colors knows that "blue full on" looks different on
different devices, hence you will need to fine tune the color table
to look nice on the device you are plotting to.
3 MIN
3 MAX
3 TOT
3 hints
PGPLOT draws pixels centered on the integer pixel location and extending
out to +/- half a pixel. Thus if you want your image to exactly fill
the plotting window, you should use
GAp 0.0 Errors
R ! reset the default scale.
The GAp 0.0 ensures there is no extra gap around the data, and the
Errors causes the error bars to be included when min/max values are
computed. Since IMAge only works when using XAx Linear and YAx Linear
this effectively includes the extra half pixel when the min/max are
computed.
PLT works equally well with both "pseudo color" and "true color" devices
(if you don't know what these terms mean you might want to read the
history topic below). Since pseudo color can only have one lookup
table active per program, using multiple color tables in different
PLT windows can result in confusion when switching from a pseudo color
device (such as a SUN X Window display) to a true color device (such
as PostScript file). To avoid this confusion you should only use
one color table for all plot windows. It is also suggested that you
define this color table in the image that appears in the lowest numbered
window i.e., the one that is plotted first. This ensures that the
color table will be correctly loaded for all following windows.
3 history
Pseudo color devices were invented early in the age of computers where
processors were slow and memory was expensive. Thus it was not
practical to store a 24 bit (Red,Green,Blue) RGB color triplet for
every pixel. What was (typically) done was store an 8 bit color index
instead which allows only 256 color indices at each pixel. However,
even early monitors could diplay more than 256 colors resulting in
a missmatch between the display adapter and the monitor.
In order to give users the ability use more than 256 colors, a lookup
table was implemented. For example, color index 2 could correspond
to Red=255, Green=10, Blue=10 a red pixel. Thus the hardware would
read the color index of a pixel, lookup corresponding color in the
color lookup table and then draw the pixel on the screen. This can
be done very quickly and is very memory efficient. Another advantage
of using a color lookup table is it can be reloaded very quickly.
For example, the IRAF image display exploits this feature by allowing
the user to change the lookup table by draging the mouse around
in the display window. Although this allows you to quickly find
a color table that enhances the features they are interested in, it
is worth noting that you are not enhancing the data, just the monitors
ability to display the data. In other words, features that are visible
when one lookup table is loaded, are still present (in the display
memory) for all the other lookup tables tried.
At the current time, it is typical for computers to display several
windows each drawn by a different program. If all these programs
can agree on a color lookup table then things work fine. On the other
hand if a program wants total control of a lot of colors (IDL and
Netscape are famous for this) then the operating system must swap
lookup tables around as the user changes from window to window,
program to program. Since the lookup table can be loaded very
quickly this results in entire monitor flashing from one set of
colors to another.
It is no longer necessary to skimp on memory. Current machines have
no problem loading 24 bit RGB indices at resolutions up to 1000 by 800
pixels (2.4 MB for display memory). In fact, since three is an odd
number most displays load 32 bits per pixel, with 24 bits of RGB data
and 8 bits of something else such as a "alpha overlay plane". This
makes true color devices possible. What true color means, is each
pixel is loaded with its true RGR color triplet, and hence there is
no color lookup table.
Thus pseudo color means a color index is stored in memory and lookup
table is used to map the color index into a RGB triplet. A true color
device stores the RGB triplet in memory.
Many people assume X Windows pseudo color, however, X Windows can
actually support either. Suns typically implement X in a pseudo color
manner whereas SGIs typically implement true color. PostScript of
course, is true color (i.e., no amount of messing with a color table
is going to change what is printed on paper.)
2 IMOdel
IMOdel [# # [#]]
Integrate the current model over the range specified by the first
two parameters. The third (optional) number, which defaults to 200,
is the number of steps.
For 2-dimensional data you can use
IMOdel
IMOdel [# # [#]] [# # [#]]
where 2nd triplet of numbers specify the lower and upper limits, and
the number of steps to use in the Y direction.
The method only uses a simple rectangle rule to calculate the integral.
2 Info
Info Call
Display the various argument values in the original call to the
PLT subroutine. Useful for programmers to figure out what they
are really telling PLT to do.
Info Groups
For each active group, display some interval variables.
Info Scales
For each active plot group display the label and data min/max
values. This is the default value.
Info Windows
Display PLT internal inforomation about the various active windows.
2 LAbel
LAbel G#|X|Y|Top|OX|OY|OTop|File [label]
Place a label. The command "LA G# label" associates a label with
a particular plot group. Thus the command sequence "LAB G1 Time;
Xaxis 1", associates the label "Time" with group 1. When the command
"Xaxis 1" executes, it makes group 1 the x-axis group, and as a result
the label "Time" will automatically appear on the x-axis.
The arguments "X", "Y", and "Top" would place a label on the x-axis,
y-axis, or the top of the plot. These labels override the Group labels
so that if the x-axis is labelled with both a group label and a x
label, then only the x label appears. When using the "Xaxis Linear"
command, "LAbel X" the the only way to label the x-axis. It is possible
to place an additional line of text just outside these locations by
putting the letter `"O"' in front of these names. For example, "OT"
would write a second label above the top label. Finally one can change
the file name by using "LA File [name]".
If you should at any time wish to delete a label, then just omit the
"[label]" from the command.
LAbel OFf
Suppress plotting of all text labels. (This speeds up the production
of the plot on slow devices.)
LAbel ON
Undo the effects of "LAbel OFf".
LAbel NX|NY ON|OFf [winlist]
where "[winlist]" is a list of windows. NX affects the plotting of
the numeric labels on the x-axis, NY on the y-axis. Thus "LAbel NX OFF 1";
"LAbel NY OFF 1", will prevent the plotting of the numeric labels in both
the x and y directions for the first window. (Note, there are 32 numbered
labels, so using "LAbel NX OFf", followed by several "LAbel #" commands
will allow you to create labels consisting of text strings etc.
LAb POS Y #
Allows the position of the y label(s) to be changed. The default
position is "LA POS Y 2.0".
LAbel Rotate
Rotate numerical labels plotted on the y-axis. The default PGPLOT
mode is to plot the y-axis numerical labels in the vertical direction.
"LAbel Rotate" will rotate these labels so they are written in a
horizontal direction. If you issue the command a second time, then
the labels will flip back to vertical in the next plot.
3 examples
PLT> LA F ! Delete the file name from the plot
PLT> LA T Test! Plot ! Top label is Test
PLT> LA T "Test! Plot" ! Top label is Test! Plot
3 Parm
LAbel Parm ON
Display the parameter values associated with the current model,
on the right side of the plot. (This is the default.)
LAbel Parm OFf
Suppress the display of the parameter values on the right side
of the plot.
3 #
LAbel # [clist] "string"
Allow a label to be placed anywhere on the existing graph. Here # is
a number in the range 1 to 32, "[clist]" is a list of subcommands that
allow you to change various attributes of the label, and ``string''
is the (optional) text. For example,
PLT> LAbel 1 Pos 2 2 "test"
will create label 1 at position (2,2) containing the message "test".
4 CEnter
LAbel # CEnter Top|Cap|Half|BAse|BOttom
Control the vertical position of the text string. The default
position is "Half", although the use of the "LIne" subcommand will
override this.
4 COlor
LAbel # COlor #
Cause the label to be plotted with color index #. (Default is color
index 1.)
4 CSize
LAbel # CSize #
Cause the label to be plotted with character size #. (Default is
character size 1.0.)
4 Justify
LAbel # Justify Left|Center|Right
Control justification of text string. (Default is left justify.)
4 LIne
LAbel # LIne # [#]
Draw line at angle # (in degrees) from position to the label.
If the second number is specified, then it will be used as the length
of the line in viewport units. (Default line length is 0.08.) If no
number follows the "LIne" command, then the line is turned off.
4 LStyle
LAbel # LStyle #
Control the line style of the line plotted, when the "LIne"
subcommand is used. (Default is 1.)
4 Marker
LAbel # Marker #
Include marker # in the text line. The default will produce a left
justified string just to the right of the marker. If you then right
justify the string, then the string will appear to the left of the
marker. In either case, the (x,y) position corresponds to the position
of the marker.
4 MSize
LAbel # MSize #
Use the specified marker size with plotting the specified numbered
label. Default size is 1.0.
4 Position
LAbel # Position # #
Specify the (x,y) location of the string in world coordinates.
When using the "LIne" subcommand, "Position # #" gives the (x,y)
location of the position being `pointed at' with the text string at
the other end. If the "Marker" subcommand is used, then "# #" refers
to the location of the marker. For other cases, "# #" is the location
of the string. The "CEnter" and "Justify" subcommands can later
override how text is plotted relative to a location. (The default
location is (0,0).)
4 TExt
LAbel # TExt one=%1% two=%2%
All the text on the line following the TExt subcommand becomes
the label. The main difference between using simple " and using TExt
has to do with the command parsing. Thus with LAb 1 "%1%" the label
would be the actual string %1% whereas LAb 1 TExt %1% would substitute
%1% with the first argument.
4 To
LAbel # To # #
Draws a line from the position specified with the Pos # # option to
the location in the To field.
NOTE: If you add a text label, the text will be plotted at the "To"
location. This is for maximum compatibility with the "LAb # LI 45 .1"
command.
Example:
PLT> LAB 1 Pos 0 1 To 0 1 " " ! Draw line from (0,1) to (1,0)
4 Rotate
LAbel # Rotate #
Plot the label at an angle of # (degrees) relative to the x-axis.
(Default angle is 0.)
4 VPos
LAbel # VPos # #
Specify the (x,y) location of the string in viewport coordinates.
When using the "LIne" subcommand, "Position # #" gives the (x,y)
location of the position being `pointed at' with the text string at
the other end. If the "Marker" subcommand is used, then "# #" refers
to the location of the marker. For other cases, "# #" is the location
of the string. The "CEnter" and "Justify" subcommands can later
override how text is plotted relative to a location.
LAbel # VPos Curs
Display the cursor at the current default position. You can move
the cursor to the desired position using the standard (PGPLOT) cursor
keys. Once at the location where you want the label, press the space
bar. The next time the plot is drawn, the label will appear at the
new location.
4 examples
PLT> LAbel 1 "TEST" ! Place the word TEST at location (0,0)
PLT> LAbel 1 P 10 10 ! TEST will now appear centered at (10,10)
PLT> LAbel 1 LIne 90 ! Draw a vertical line from the point (10,10) to
! the word TEST.
PLT> LAbel 1 CO 3 ! Color line and word TEST green
PLT> LAbel 1 P 10 10 LIne 90 CO 3 "TEST" ! Does all the above in a
PLT> ! single command
2 LIne
LIne ON [glist]
Draw a line connecting all the points in each plot group specified
in "[glist]".
LIne OFf [glist]
Produce a scatter diagram by turning off the line for each plot
group specified in "[glist]".
LIne Stepped [ON] [glist]
Produce a stepped-line plot for each plot group specified in "[glist]".
LIne # [ON] [glist]
PLT always draws straight lines between mesh points and the default
is each data point corresponds to a mesh point. When plotting a line
it is sometimes useful to use more mesh points than data points.
The LIne # will force PLT to use ABS(#) mesh points. If # is greater
than zero, then the line is evaluated at # points between the current
x-scale Minimum and Maximum. If # is less than 0, then the line is
evaluated at "ABS(#)" points between the Data Min and Data Max ---
i.e., no extrapolation is allowed. If # equals 0, then the line is
evaluated at the data points. (This is the default.) If a mesh point
lies between two data points then a cubic spline using Akima
coefficients is used to evalute the location of the mesh point. This
gives the illusion that a smooth line connects the data points. Note:
this command will only work if the x values are strictly increasing.
Note: If you set "Error OFf", "MArker OFf", and "LIne OFf", then
the line will still appear. The only way to prevent data from being
plotted is to use the "COlor OFf" command.
3 examples
PLT> LIne ON ! Use a line for all groups
PLT> LIne OFf 1,3 ! Turn off the line for groups 1 and 3
PLT> LIne Step 1,5 ! Plot groups 1 and 5 with a stepped line
PLT> LIne 200 ON 2 ! Plot 'smooth' line on 200 points over current X range
PLT> LIne -200 ON 3 ! Plot 'smooth' line over 200 points from data min
! to data max
2 LOCation
LOCation # [# [# [#]]]
The "LOCation" command allows you to control the location of the
currently active window. The default location of all windows is
0. 0. 1. 1. which means that all windows overlap and use the entire
plotting surface. This command in combination with the "WIndow" command
allows great control over where the windows are plotted. Thus a small
window could be plotted inside a larger one. However, no attempt
is made to erase a plotting region, so overlapping windows could result
in overlapping text.
3 examples
To create 4 windows in the 4 quadrants, use:
PLT> WIndow 1
PLT> LOCation 0 .5 .5 1.
PLT> WIndow 2
PLT> LOCation .5 .5 1. 1.
PLT> WIndow 3
PLT> LOCation 0. 0. .5 .5
PLT> WIndow 4
PLT> LOCation .5 0. 1. .5
2 LOg
LOG X|Y|X,Y ON|OFf [winlist]
Controls whether a log scale is used when plotting in the windows
specified in "[winlist]". Thus "LOG Y OFf 2 3 4", would turn off
the use of a log scale in the y direction in windows 2 3 and 4. Also,
"LOG X,Y OFf 3" would turn off the log scale in both the x and y
directions when plotting in window 3.
2 LStyle
LStyle # [ON] [glist]
Change the default line style for the plot groups specified in
"[glist]". The first number is the style type. Note, glist can
also contain 'Model' to change the line style when plotting the
current model, or 'Grid' to change the line style when plotting
the grid in the currently active window.
LStyle ?
List possible line styles.
3 examples
PLT> LStyle 2 ON 3 ! Use line style 2 when plotting group 3
PLT> LStyle 1 ! Use solid line when plotting all groups
PLT> LStyle 5 ON 1,4 ! Use line style 5 when plotting groups 1 and 4
PLT> LS 2 ON 3,MOD ! Use line style 2 when plotting group 3 and the
! current model.
2 LWidth
LWidth # [ON] [glist]
Set the line width to the value #. Allowed values are 1 or greater.
On some laser printers, the default line width is very narrow and
so, using thicker lines will enhance the output quality. If glist
is omitted then this command resets the default line width for the
entire plot. If you list some group numbers in glist then the groups
listed in glist will no longer be plotted with the default line width
but rather with the line width you specified. Also, glist can contain
the word 'Model' to change the default line width when plotting the
current model.
3 examples
PLT> LWidth 3 ! Triple the default thickness of all lines
PLT> HArd /PS ! and make a hardcopy
PLT> LWidth 1 ON 2 ! Plot group 2 with line width 1. The rest of the
! plot will still be plotted with line width 3.
PLT> LW 3 ON MOD ! Plot current model with line width 3.
2 MArker
MArker [#] ON [glist]
Turn on the plotting of polymarkers. The first (optional) number
is the marker type; if omitted the default marker type will not be
changed. If "[glist]" is omitted, then markers will be used to plot
all plot groups.
MArker OFf [glist]
Turn off the plotting of markers for all plot groups specified.
If "[glist]" is omitted, then markers will be removed from all groups.
MArker Size # ON [glist]
Changes the size of the markers when plotting the plot groups
specified in "[glist]". The size can range from 0.0 to 5.0, where
1.0 is the default. Thus every plot group can have a different marker
size.
MArker ?
Draw a table of all the PGPLOT markers on your current graphics
device.
3 examples
PLT> MArk 19 ON 2 ! Use marker 19 when plotting group 2
PLT> MArk OFF 2 ! No longer plot group 2 with a marker
PLT> MArk ON 2 ! Use default marker when plotting group 2
PLT> MArk ON ! Use markers when plotting all plot groups
PLT> MArk Size 5 ! Plot markers 5 times larger than default size
2 MMaster
MMaster iwnum X|Y|XY wlist
MMaster iwnum Off
Use this command to slave the scales of the windows listed in the window
list (wlist) to that of the master. For example if you use
MM 1 X 3 4 7
Then every time you change the X scale in window 1 then the X scales
of windows 3, 4 and 7 will also be updated to be the same as what is
in window 1. Any attempt to change the X scale of windows 3, 4, and 7
for example using a "R X4" type command, will be ignored.
3 example
! Plot
WIN 1
LOC 0 .5 .5 1
YPL 1
! Create window 2 in upper right corner and put the model in it.
WIN 2
LOC .5 .5 1 1
YPL 2
! Create window 3 in bottom left corner and put residuals in it.
WIN 3
LOC 0 0 .5 .5
YPL 3
! Sync everything to window 1
WIN 1
MM 1 xy 2 3
r 600 800 550 750 ! Scales for Windows 1, 2, and 3 are all affected.
2 MOdel
See definition subtopic for help on creating models.
MOdel ?
List all built-in model components.
MOdel @filename
Cause the model definition and parameters to be read from the file
with name "filename". Although chi^2 is written to the model file
it is important to refit before issueing an UNcertain command. This
is to avoid potential problems with roundoff errors.
3 definition
A model consists of several components that are added together.
For example, "MOdel CONS LINR QUAD" will add a constant term, a linear
term, and a quadratic term.
For each parameter required by the "MOdel" command, you will be prompted
for four numbers --- "VAL", "SIG", "PLO", and "PHI" --- as described below.
For each parameter, you should enter an initial value for "VAL"; but
you can usually default on the other three numbers.
"VAL": This is the actual value of the parameter. Although CURFIT
will often find the the best set of parameters to model the data, it
never hurts to start it with parameters near the expected best fit.
"SIG": Any value of "SIG">=0 will not affect the outcome of "Fit".
After you fit the model, "SIG" will contain the one-sigma curvature
errors. This number is used by the "Uncertainty" command to start
a formal error determination. If the "Uncertainty" command fails
to converge because the original error estimate is wrong, sometimes
you can improve the convergence by adjusting "SIG" to be a better
estimate before using "Uncertainty". If you set "SIG=-1", then the
parameter is frozen such that CURFIT is not allowed to change the
parameter value while fitting. If you set "SIG"=-IPAR, the next number
("PLO") will default to 1, such that the current parameter value is
forced to equal the value of parameter IPAR. (Note: IPAR can not
equal 1 or the current parameter number.) If you place a number (N)
after "SIG", this will force the current parameter to be N times the
specified parameter. (N defaults to 1.0.)
PLT> MOdel GAUS GAUS
1, GC: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
,-4,2
2, GW: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
3, GN: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
4, GC: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
2.
5, GW: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
6, GN: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
defines a model consisting of two gaussians, with the x values of
the centers differing by a factor of 2. Although you did not enter
a value for parameter 1, it will be set to the value of 6 (2 times
value of parameter 4). This relation will be maintained throughout
a fit.
PLO, PHI: If SIG>=0 and if PLO
: NGAUS ! The file must contain a : followed by a dummy name
X ! Push current value of X onto the stack
X ! Push current value of X onto the stack
* ! Multiply the top two numbers on the stack to get X*X
P1 ! Push the value of parameter 1 onto the stack
* ! Multiply to get P1*X*X
NEG ! Negate the number on the top of the stack (-P1*X*X)
EXP ! Calculate EXP of -P1*X*X
P2 ! Push the value of parameter 2 onto the stack
* ! Multiply to get P2*EXP(-P1*X*X)
; ! The function must end with a ; character
This simple COD function ("NGAUS.COD") contains two parameters and
calculates the value of "P2*EXP(-P1*X*X)". It could be written much
more concisely as
: NGAUS X X * P1 * NEG EXP P2 * ;
2 Newpar
Newpar
Display the values associated with all of the parameters and allow
the user to change them. If you wish to display the parameter values
without changing them, then use the "WModel" command.
Newpar #
Display the values associated with the parameter specified by the
first argument. You can either enter return, leaving the parameter
values unchanged, or enter new values.
Newpar # #
Change the value of the specified parameter to the value you entered
in the second (and following) arguments. You will not be shown the
original values.
3 examples
PLT> Newp 2 ! Prompt for new values of parameter 2
2, GW: VAL( 1.00), SIG( 0.00 ), PLO( 0.00), PHI( 0.00)?
3. ! Value of parameter 2 is now set to 3
PLT> Newp 3 10 ! Value of parameter 3 is now set to 10
PLT> Newp 6,,-1 ! Freeze value of parameter 6
2 PAper
PAper # #
Resets the default size and aspect of the display/printing surface.
The first number is the width of the plot in cm, the second number is
the aspect ratio (height/width). This command uses the PGPLOT internal
value for the resolution of the graphics device, and for some device
types (such as displays) is only approximate. Some device types
will ignore attempts to change the size.
Use PAper 0 0 to reset to the default page size. Due to the way PGPLOT
works, you may need to issue the CPD command to reinitialize the
device to the correct default.
2 Plot
Plot
Cause the plot to be redrawn on the graphics device.
Plot All
Cause all data points, including those flagged as no-data, to be
plotted.
Plot Good
Undo the effects of the "Plot All" command and prevent plotting of
points flagged as no-data (default).
Plot Vertical
Plot up to 20 plot groups in separate panels, in a vertical stack.
Plot Overlay
Plot all groups in a single panel (default).
Plot Zero ON
Cause the plot groups that have color index zero to be plotted
with the background color. This is sometimes useful for erasing plots.
Plot Zero OFf
Do not plot groups with color index zero (default). This is much
faster than plotting with the background color.
3 Vertical
Plot groups in separate windows in a vertical stack, with one plot
group plotted in each window. For maximum compatibility with earlier
versions of PLT, the windows are number with the group number. Thus
group 3 is plotted in window 3. This allows commands like Rescale Y3
to rescale the window containing group 3.
After you execute the Plot Vert command all the windows are treated
as a single entity for both the `Rescale X' and `LAbel X' commands.
Thus after a Plot Vert, using a Rescale X command will cause all visible
windows to have the same X scale. Likewise, LAbel X will place the
X label on the bottom window of the stack. This behavior will continue
until you use the Window # command to select a given window, afterwhich
the Rescale X and Label X commands will only affect the selected window.
The WIndow All command can be used to restore the behavior where
Rescale X affects all windows. The only way to restore the LAbel X
behavior is to reissue the Plot Vert command.
2 PRompt
PRompt $
Redefine the ``PLT>'' prompt.
2 Rescale
Rescale X [#] [#]
Reset XMIN and XMAX in the current window to the values specified.
both XMIN and XMAX are omitted, then PLT will reset the range to
the default.
Rescale Y [#] [#]
Reset YMIN and YMAX in the current window to the values specified.
If both YMIN and YMAX are omitted, then PLT will reset the range to
the default.
Rescale [#] [#] [#] [#]
Reset XMIN, XMAX, YMIN, and YMAX in the current window to the values
specified. If all four numbers are omitted, then PLT will reset both
the x- and y-ranges to the defaults.
Rescale ?
Display the current XMIN, XMAX, YMIN, and YMAX values for each
window.
Note: For Vertical plots each window can be specified separately;
thus "R Y1" will rescale the y-range in window 1 and "R Y4" will
rescale the y-range in window 4.
2 SCr
SCr # # # #
Immediately change the color representation for the specified color
index. The first number is the color index and the following three
numbers give the red, green, and blue color intensities and must lie
in the range 0.0 to 1.0. This command only works on color devices
for which the color representation can be changed.
For color indices 0-15, the color representation you set will become
the new default for as long as you stay in PLT. This means the HArdcopy
command will show the colors you have set (if the device is capable).
To restore the original default colors use set the Red color value
to NO and then reissue the cpd command. Thus to restore the default
color representation of color index 2 on your default /xs device,
use:
PLT> SCR 2 NO
PLT> CPD /xs
PLT> P
Note, for PostScript files, color index 0 is *anyways* transparent
and thus the color of the paper. I.e., there is no way to change
the background color (other than loading different color paper in
the printer) for PostScript files. If you want to change the background
color, use the /PNG device.
3 Black/White/Default
SCr [Black|White|Default]
This allows PLT to override the default PGPLOT background color.
In particular, /XS and /GIF devices produce white lines on a black
background, whereas a PostScript hardcopy would be black lines on
white paper. Thus
PLT> SCr White
will always force the background to be white. Note, SCr Black is
not recommended as it would require white toner and black paper in
order for it to work with PostScript devices. SCr Default restores
the default behavior where PGPLOT picks the background color.
3 examples
PLT> SCR 0 1. 1. 1. ! Set the background color to be white
PLT> SCR 1 0 0 0 ! Plot color index 1 in black
PLT> SCR 2 0 1 0 ! Plot color index 2 in green
3 SEt
Allows user to set various PLT internal variables. Currently you
can only set the maximum length of lines written with the WData command.
PLT> SEt LEngth 64 ! Don't write lines longer than 64 characters.
2 SHow
Allows user to show the current values of various PLT internal
variables. Currently you can only show the maximum length of lines
written with the WData command.
PLT> SHow
LEngth 256 ! Maximum length of lines written with the WData command.
2 SKip
Most PLT commands operate on `groups' of data points. The default
is for each vector of the input data to be in a separate group. For
the default mode, commands like "COlor" and "MArker" affect the
appearance of an entire vector. Using the "SKip" command, it is
possible to independently control the appearance of sub-sets of data
within a single vector. Thus, when using "SKip", a single y vector
can be divided into several plot groups that can be independently
controlled with "COlor", "MArker", "R Y1", etc. Currently, "SKip"
should only be used when the input data consists of two vectors as
the other vectors will not be plotted. Note, "SKip" cannot affect
whether a data point has an error associated with it.
SKip OFf
Each vector of the input data is plotted as a separate group
(default).
SKip Single
A new plotting group begins every time x-coordinate equals "NO" (the
no data flag) ONE or more consecutive times. "SKip Single" is useful
when you wish to plot different groups with different markers.
SKip Double
A new plotting group begins every time x-coordinate equals "NO" (the
no data flag) TWO or more consecutive times. "SKip Double" is useful
when you wish to plot different groups using lines that contain breaks.
3 example
Consider the QDP file:
1 2
2 1
NO NO
3 4
4 3
NO NO
NO NO
5 6
6 5
With the default "SKip Off", the above will be plotted as two groups
each containing nine points. Using "SKip Single", would cause the above
data to be divided into three groups. The first group would consist
of the data in the first three lines, the second would come from lines
four to seven, and the third group from lines eight and nine. Using
"Skip Double" would cause the above data to be plotted as two groups
with lines one through seven being in the first group and the last
two lines making the second group.
2 STatistics
STatistics [fgroup]
where "[fgroup]" is the default group for fitting. This
command causes a short table to be printed on your terminal that
displays some basic statistical properties about that group of data.
The first line tells you which group is fitted and over what range.
Next the unweighted average, variance, and 3rd moment are displayed.
For the unweighted data, the column labeled "SUMW" contains the total
number of points used in the calculation, for weighted data, "SUMW"
is the sum of the weights. "YMIN" and "YMAX" are the minimum and
maximum data values in the range. If the plot group has errors
associated with it, then weighted values of the average, variance,
and 3rd moment will be displayed. The next row contains "WCHI" and
"WRED" which are the chi^2 and reduced chi^2. The "W" is appended
to remind you that the actual errors on the data were used. The line
labeled "Sum of Y*XDEL" contains the sum of the y values times the
Delta x values, where Delta x is given by the x-error bars. This
is a rectangle rule integral of the data. The last line gives the
(unweighted) linear correlation coefficient of the y vs. x data.
For maximum accuracy, this routine makes two passes through the data,
once to calculate the average, and the second time to calculate moments
based on the difference between the data and the average.
If you don't understand the difference between the unweighted and
weighted values then you should use unweighted quantities.
3 example
PLT> STat
Group 2, from 430.0 , to 540.0
YBAR YVAR Y3M SUMW YMIN YMAX
UNWTD 0.5915 0.1341 -8.3771E-03 23.00 2.2100E-02 1.096
WTD 7.8728E-02 2.0009E-02 1.2435E-02 4.9056E+05
WCHI= 9.389E+03, WRED= 426.768
Sum of Y*XDEL= 0.883411
Correlation coeff.= -0.853596
2 THaw
THaw [plist]
Can only be used after a model has been defined. This command
causes all parameters listed in "[plist]" to be thawed, which means
the parameter value will be allowed to vary when fitting.
3 examples
PLT> THaw 2 ! Cause parameter 2 to be thawed
PLT> THaw 3..5 9 ! Cause parameters 3 through 5 and 9 to be thawed
2 Time
Time ON
Cause the date and time to be plotted in the lower right corner
(default).
Time OFf
Remove the date and time from future plots.
2 Uncertain
Uncertain [# [# [#]]]
Vary the specified parameter(s) in order to estimate their
uncertainties. Each specified parameter, in turn, is stepped and
chi^2 is minimized. Stepping stops when the requested value of
Delta chi^2 is obtained. "Uncertain" can take up to 3 numbers as
arguments. If one number contains a decimal point, then that number
is interpreted as the requested value of Delta chi^2 (which for the
first time defaults to 2.7 and for later times defaults to the previous
value). The remaining two numbers in the "Uncertain" command specify
the lower and upper parameter numbers for which you want to estimate
the error. If only one number is given (without a decimal point),
then the error is generated only for a single parameter. If errors
are currently turned off (or do not exist), then the routine works
out a correction factor that converts the W-VAR to chi^2.
2 UPper
UPper # ON [glist]
If a number in one of the groups specified in glist is less than
# sigma from zero, then plot that number as a #-sigma upper limit.
3 example
PLT> UPper 2.7 ON 3 ! When plotting group 3, all numbers within 2.7
PLT> ! sigma of zero will be plotted as an upper limit.
2 VErsion
VErsion
Return the date of last modification to the current version of PLT.
2015-06-12 - Call FRELUN if WModel command fails.
2015-06-11 - 'Model insensitive to parameter' had gone away...
2014-02-04 - Fixed bug reading mal-formed model (.mod) files.
2012-11-05 - Ignore NO data values when plotting residuals.
2012-03-23 - Additional check when reading CMD array.
2011-04-20 - Internal bug fixes.
2011-01-14 - SCR B/W does not restart plot device.
2010-11-10 - Fix bug in SEt LEngth command.
2010-09-23 - Add the LY (Linear in Y) component.
2010-07-13 - Fix plotting bug when SKip ON reduces the number of groups.
2010-07-13 - Fix format for WHead with IMAge MIN less than zero.
2010-06-30 - If FPNUM finds an error, it now returns NO (was 0.0).
2010-06-03 - Fix another image related WH bug.
2010-06-01 - SCR (for indices 0-15) is remembered.
2010-05-28 - Several fixes to WH command.
2010-05-26 - Another XAX/SKIP bug fixed.
2010-05-20 - Fix 20 year old error in example fig04.pco.
2010-04-23 - CURFIT would randomly pick 0.001 as a stopping condition.
2010-03-29 - Xaxis # refers to vectors not groups (software and doc).
2010-03-25 - New SEt/SHow to change maximum length of lines written with WD.
2010-03-24 - Fix potential infinite loop in spline/akima components.
2009-07-02 - When FIT plots final model, it no lonver redraws the labels.
2009-03-10 - Increase MXLAB to 200.
2008-12-16 - Splines handle too many knots before asking user for all pars.
2008-03-17 - LAb # To now works correctly with log coordinates.
2007-09-17 - Increase MXLAB to 100.
2007-04-05 - Contour plots written with WE should now work.
2007-02-02 - Upper limits now plot correctly on LOG scale.
2007-01-08 - The sequence Fit/UN/Fit now works with splines.
2007-01-08 - MO @file/UNcer 2 is now illegal (and never worked correctly).
2006-08-31 - STat command works again.
2006-08-30 - Fit now works if x coordinate is decreasing.
2006-04-10 - Fit Plot -100 (negative number) should now work (again).
2005-09-22 - CURFIT now always writes out the "model insensitive to" error.
2005-08-24 - YAX LIN now affects groups not windows (like XAX LIN).
2005-08-15 - WM adds parameter numbers as comment, mo @ ignores comments.
2005-06-29 - Fix use of GETLUN/FRELUN when using WEnvir.
2004-07-22 - Add LAb # Pos x1 y1 To x2 y2 option.
2004-02-27 - Fix bug that caused "LAb 1 VPort Curs" to fail.
2004-02-24 - Fix bug that prevented same COD file from being used twice.
2004-02-04 - In cod functions, "ASLO" no longer matches "ASin".
2004-01-22 - Fix case where MA ? would be displayed in background color.
2003-07-21 - LIne Step now works if X-coordinate is decreasing.
2003-07-17 - Fix crashes when user uses an undefined group.
2003-04-15 - GRid ON now works with images.
2002-08-02 - Fix bug where PLT incorrectly decides no points are in fit range.
2002-04-02 - Model is now plotted for entire displayed range not fitted range.
2002-03-21 - Add CGau and NCGa built-in functions.
2002-03-19 - SCR [White|Default|Black] added to set default background color.
2002-03-18 - Cursor keys now work with xterms (change to cget.f).
2002-01-22 - STat and IMOdel commands now works with 2D groups.
2002-01-22 - Y range limit implemented for 2D fitting.
2002-01-22 - Fix calling of PLTSVW from PLTCUR routine.
2002-01-17 - Increase to MXPAR=120, MXFREE=100 (computers are faster).
2001-07-18 - "err sq y", "gap err", "r y" now correctly sets the scale.
2001-04-30 - rdqdp now ignores blank lines.
2001-04-23 - YPL # no longer "forgets" if # had been DG'ed to be a 2D group.
2001-04-23 - WH does a better job at writing DG commands.
2001-03-29 - Fix bug in COD a2tn function incorrectly testing for 0,0 case.
2000-10-06 - Fix LAB # ma 2 lin 90 .02 failing on some devices.
2000-10-04 - If using XAX LIN; ERR OFF; STAT, then sum Y*XDEL will be correct.
2000-08-23 - Initilize the fit group var before it is used...
2000-08-10 - Error [X,Y] Gehrels sets the error to 1+SQRT(0.75+N).
2000-08-08 - Error X Sq now works again.
2000-07-03 - bug fix, can now see fits to groups.GT.10.
2000-06-15 - "LIne # on" now works again.
2000-06-14 - If X value is NO then point is ignored in fitting, etc.
2000-02-18 - Fix contour bug that sometimes prevented contours from appearing.
2000-01-25 - DGroup #; XAX # now works correctly.
2000-01-13 - IMA CCT file, now searches same path as scripts.
1999-09-09 - Fix default plotting when using SKip ON, sigh.
1999-09-05 - Scale the CURFIT errors when using "ERR OFF/FIT STAT CHI".
1999-09-05 - Fix bug when using "ERR OFF/FIT STAT ML".
1999-09-05 - Initialize variable qhard to make g77 (and others) happy.
1999-05-20 - DGroup 4 Res; YPlt 4 now work for line plots.
1999-05-17 - Fix bug introduced by inline models.
1999-05-11 - Fix default plotting when using SKip OF.
1999-04-29 - Make inline model files more transparent.
1999-04-22 - Add optional call to hdecod to rdqdp.f.
1999-04-21 - Can include model parameters in QDP files by enclosing in quotes.
1999-04-16 - Add the MMaster commend.
1999-04-15 - WH now writes DGroup commands.
1999-04-14 - Fix bug when WH writes R X command.
1998-12-17 - Line Step now works (again) if no X error bars
1998-11-25 - Groups can now have independent LOG/LIN/SQRT image scaling.
1998-11-18 - DGroup [Model|Residuals] now working properly.
1998-10-06 - PLT no longer does an "Error OFf" if plotting > 2000 points.
1998-10-05 - Redid internal data structures for the X coordinate.
1998-10-01 - Fixed up Fit Stat ML (see HElp FIt statistics for details)
2 Viewport
Viewport #,[#,[#,#]]
Control location of the viewport in normalized device coordinates,
where (0.0,0.0) is the bottom left corner and (1.0,1.0) the top right
corner. The default viewport is 0.1 0.1 0.9 0.9, with the first two
numbers giving the location of the bottom left corner and the next
two numbers, the upper right corner. If you use "Viewport" with and
only specify two numbers then PLT centers the viewport about the center
of the plot, thus "View x,y" is the same as "View x,y,1.0-x,1.0-y".
If you do not wish to center the viewport, then you can specify all
four numbers, where the last two numbers refer to the top right corner.
3 examples
PLT> View .4 .4 ! Viewport extends from (.4,.4) to (.6,.6)
PLT> View .8 .8 .9 .9 ! Use small viewport in top right corner
PLT> View .1 .1 ! Go back to the default viewport
2 WData
WData [$]
Write all data between the current x-scale minimum and maximum
to a QDP file. If you want all the data to be written to the file
then you should use the "R X" command to reset current scale to include
the minimum and maximum data values. A blank file name will cause
the data to be written to your current terminal screen.
The "WData" command will not write any PLT commands to the file.
However, it will include a reference to an indirect file. For example,
"WData TEST" will create a file called "TEST.QDP" that includes the
line "@TEST". The PLT command "WHead" can be used to create a "TEST.PCO"
file that contains all the PLT commands needed to re-create the current
plot.
WData [$] #
Write the data with only # digits of accuracy (numbers will be
rounded). If # is negative, the error on a number is written out to
(-#) number of digits and the number itself is written to the same
accuracy.
3 examples
PLT> WData ! Write the data to the terminal screen
PLT> WData TEST ! Write the data to TEST.QDP
PLT> WData TEST 3 ! Write the data (3 significant digits) to TEST.QDP
PLT> WData TEST -2 ! E.g., 123.758 +/- 2.698 will be written 123.8 2.7
PLT> WData,,-2 ! As above, but written to the terminal screen.
2 WEnviron
WEnviron [$]
This command does the same thing as if you entered a "WHead" command
followed by a "WData" command. This command should be used if you
want to save both the current data and the PLT commands needed to
re-create the current plot.
3 examples
PLT> WEnvir ! Write commands and data to the terminal screen
PLT> WEnvir TEST ! Create TEST.PCO and TEST.QDP files
PLT> WEnvir TEST 3 ! Write the data (3 significant digits) to TEST.QDP
PLT> WEnvir TEST -2 ! E.g., 123.758 +/- 2.698 will be written 123.8 2.7
PLT> WEnvir,,-2 ! As above, but written to the terminal screen.
2 WHead
WHead [$]
This command only writes the list of PLT commands needed to create
the current figure. Since this command will NOT write any data, it
will run faster than the "WEnviron" command. Typically one would
first use "WEnviron" to write both the PLT commands and the data to
files. If any changes are made to the appearance of the plot
(such as adding labels, etc.) then the "WHead" command can be used
to update the PLT command file without over-writing the QDP file
containing the data.
3 examples
PLT> WHead ! Write commands to the terminal screen
PLT> WHead TEST ! Write commands to TEST.PCO
PLT> WHead TEST 3 ! Same as previous (the 3 is ignored)
2 WIndow
WIndow #
This command sets the currently active window to be the number
specified by #. After the window command has been issued, commands
like "Rescale X", "LA Y" will affect the currently active window.
For maximum compatibility, a "Plot Vertical" command creates N windows
numbered by the number of the plot group that they contain. Thus
if group 1 is used on the x-axis, then the upper (first) window plotted
will contain plot group 2 and will be plotted in window 2.
To return PLT to the default mode where commands affect all windows,
use the "WIndow All" command.
2 WModel
WModel [$]
Write the current model into the named file. The model written
out can later be read with the "MOdel @filename" command. If you do
not enter a file name, the model will be written to your terminal
screen. Since all significant digits are written, writing a file
provides a good way to save your current "MOdel" parameters.
If you have previously "Fit" the data then this command will write
two additional lines at the end of the model file as comments. These
lines contain the WVAR and NBIN determined in the most recent fit.
2 Xaxis
Xaxis #
The X-axis can be any column containing coordinates (not errors)
in the original data. Errors are considered to be attached to the
coordinate and a coordinate with any errors is called a vector. Thus
"Xaxis 3" will use the 3rd vector to define the X-axis. Note, different
plot windows can have different defining X coordinates.
Xaxis Linear # #
Cause the x variable to be a linear function. Thus, the command
"Xaxis Linear 10. 1" would cause the first point to be plotted at
x=10, the second point at x=11, the third at x=12, etc.
2 YAxis
Yaxis Lin # #
Specify the y-axis coordinate to be used in the current plot
window. This is only useful when plotting 2D data.
3 example
Assume you have a 10 by 10 array of data, then the commands then
PLT> Xax L 10 1 ! Would cause the X values to range from 10 to 19
PLT> Yax L 5 1 ! Would cause the Y values to range from 5 to 14
PLT> CON Lev 1,2,3 ! Draws a contour plot with these scales
2 Yplot
Yplot [ON|OFf] [glist]
where "[glist]" is a list of plot groups. This command is more
intuitive to naive users than the "COlor ON|OFf" command. This command
causes the plot groups specified in "[glist]" to turned on (plotted)
in the currently active window.
2 $
$ [command]
Spawn to the operating system, where "[command]" is an operating
system command. If no command is specified, then a system shell is
created that will allow you to enter several commands until you logout
(under VMS) or exit (under UNIX or DOS).
3 examples
PLT> $ ! Spawn to system
Spawning... ! Wait for something to happen
$ # enter UNIX commands
$ exit
PLT> ! You have now returned to PLT
PLT> $ ls ! This will display your current directory
Spawning... ! Wait for something to happen
(directory appears here)
PLT> ! and you are left in PLT.
2 @
@ $
Execute commands from an indirect command file. Command files
can be nested to a depth of 10. The default file type is ".PCO" (for
Plt COmmands).
3 example
PLT> @nice ! Execute the PLT commands in the file nice.pco
2 fortran
PLT is a Fortran program with the following calling sequence:
SUBROUTINE PLT(Y, IERY, MXROW, NPTS, NVEC, CMD, NCMD, IER)
REAL Y(*)
INTEGER IERY(*), MXROW, NPTS, NVEC, NCMD, IER
CHARACTER CMD(*)*(*)
C---
C General plot subroutine.
C---
C Y(*) I The data array. The array should be dimensioned
C Y(MXROW,MXCOL) where MXROW and MXCOL are the actual
C sizes of the arrays in the calling program.
C MXCOL=NVEC+NSERR+2*NTERR where NSERR is the number
C of vectors that have symmetric errors and NTERR
C is the number of vectors that have two-sided errors.
C IERY(*) I =-1 plot errors as SQRT(Y)
C = 0 no errors.
C =+1 explicit symmetric errors.
C =+2 for two-sided errors
C MXROW I The actual first dimension of the Y array.
C NPTS I The number of points to plot (NPTS<=MXROW).
C NVEC I The number of vectors to be plotted.
C CMD(*) I Array of commands.
C NCMD I Number of commands.
C IER O Error flag, =-1 if user entered EOF, =0 otherwise.
2 history
The QDP/PLT program has evolved over a long period. In the late
1970's Andy Szymkowiak wrote a QDP (Quick and Dirty Plotter) program
for the PDP 11/70 used by the X-ray group at Goddard Space Flight
Center. This original QDP would read an ASCII file and produce a plot
on a Vector General device. It was then possible for the user to
issue commands interactively that would affect the appearance of the
plot. When the user achieved the desired plot, it was a simple
matter to produce a `hardcopy' of the plot on a Versatec printer/
plotter.
I, Allyn Tennant, quickly adopted QDP and started to add some new
features to it. In 1983 I moved from Goddard to Cambridge, England
to join Andy Fabian's group, and took along the idea of QDP program.
Rather than port the existing code, it was decided it would be best
to start over and to rewrite the code with the following goals:
1) The plotting routine would be isolated from all other activities
such as reading data from disk. A separate routine was provided
to read ASCII (QDP) files.
2) All of the author's scientific graphics would be done with PLT.
Thus when a new function was needed it would be added to PLT. This
would be done in such a way that existing software would not need
to be modified to use the new function.
3) The interface to the low level graphics routines would be minimized.
Thus all high level functions would be written in Fortran and hence
be portable to new systems. This goal was met by using the PGPLOT
graphics package.
Over the years, the goal of always using PLT to produce line graphics
has resulted in the slow accretion of functionality, so that now the
QDP name has been changed to stand for the Quick and Dandy Plotter.
PGPLOT has now been ported to several systems and, in addition, there
is a version of PGPLOT that works with GKS.
The appearance of MONGO on Starlink in 1984 influenced the evolution
of PLT. Up to that time, the only way to change the defaults was
for the user to type in a command. When MONGO appeared, it was realized
that the calling program could also issue some commands to PLT.
At this time, the calling sequence to PLT was updated to allow a command
list to passed to it. PLT can now be completely controlled through
this command list: It will never again be necessary to change the
calling sequence.
The development of PLT at Cambridge was influenced by the interaction
with Rick Shafer and his XSPEC program. Rick and I would often
compete to design the `most user friendly interface'. This resulted
in the free exchange of ideas between XSPEC and PLT; as a result,
these programs now have similar (but not identical) user interfaces.
One of the strengths of QDP has always been its ability to FIT the
data. With the original Goddard version, it was possible to fit either
a constant or a line through the data. At Cambridge, PLT was enhanced
to allow fitting of any linear combination of `components'. The list
of components slowly grew to include many functions such as sine,
exponential, log, and two types of spline. In order to keep the
specialized components from becoming part of the standard PLT/FIT
program, a user model was created. This allows users to link a
program using PLT/FIT that contains a single specialized component.
This component could then be added to components from the existing
list of built-in functions to construct an advanced model. While
workable, this method entailed making people link `private' versions
of standard programs.
In late 1987, development started on a new way to define a model
component, that would entail reading a `program' stored in an ASCII
disk file. Clearly the program would be an interpreted language and,
for maximum speed and efficiency, this language would need to be
stack oriented. Hence, COD (COmponent Definition) files were created.
Although COD is now an integral part of QDP/PLT/FIT, the programming
language itself is still evolving.
In 1988, Allyn Tennant moved from Cambridge to the Marshall Space
Flight Center in Huntsville. All questions, complaints, requests,
etc., should now be directed to Huntsville.
In early 1989 the first edition of the User's Guide was produced for
distribution by the EXOSAT group at ESTEC. I'm grateful to Nick White
for his encouragement of this effort and to Steve O'Dell who greatly
assisted in producing the original LaTeX version of the manual.
Finally, many people have contributed ideas for additional features
and many of these have been included. You are still encouraged
to suggest enhancements (yes, you are even encouraged to point out
minor bugs).
2 QDP_commands
QDP commands must be inserted at the beginning of a QDP file, as
these commands tell QDP how to read in the data. Any command not
recognized by QDP is passed to PLT. QDP separates command lines from
data lines based on the first non-blank character in the line. If
this character is + - . or a digit then the entire line will be read
as data.
3 READ
4 Serr
READ Serr [vlist]
Tell QDP/PLT which vectors have symmetric errors. The command
"READ Serr 1 3 5" will cause vectors 1, 3, and 5 to be read with
symmetric errors and vectors 2 and 4 to be read without. Only one
"READ Serr" command should appear in a QDP file
Example:
READ Serr 1 3 5
1. .1 2. 3. .3 4. 5. .5
would be read as 5 vectors; 1. +/- .1; 2. (no error); 3. +/- .3;
4.(no error); 5. +/- .5. Without the "READ Serr" command, the above
would be read as 8 vectors.
4 Terr
READ Terr [vlist]
Tell QDP/PLT which vectors have two-sided errors. It takes three
columns to specify a vector with two-sided errors. The first column
is the central value, the second column, which must be positive,
specifies the upper bound, and the third column, which must be negative
or zero, specifies the lower bound.
Example:
READ Serr 1
READ Terr 2
1. .1 2. +.1 -2.
would be read as 1. +/-.1; 2 +.1,-2. Note: In fitting, non-positive
errors are ignored and so, the first error, of two-sided errors,
should be positive.
fv5.5/tcltk/plt/pltcct.f 0000644 0002207 0000036 00000011456 13224715127 014110 0 ustar birby lhea SUBROUTINE PLTCCT(Ctable, Ltable)
CHARACTER Ctable*(*)
INTEGER Ltable
C---
C Change Color Table.
C From PGPLOT manual I = 0.30*R + 0.59*G + 0.11*B
C---
C Ctable I
C Ltable I
C---
INTEGER MXCOL
PARAMETER (MXCOL=256)
REAL FPNUM
INTEGER LENACT
C
CHARACTER cbuf*256, cnam*256, ctmp*256
REAL bint(MXCOL), gint(MXCOL), rint(MXCOL), rnci(MXCOL)
REAL bint1(2), gint1(2), rint1(2), rnci1(2)
REAL bint2(4), gint2(4), rint2(4), rnci2(4)
REAL bint3(7), gint3(7), rint3(7), rnci3(7)
REAL tmp
INTEGER i, ier, invert, ios, is, itab
INTEGER kp, lbuf, ltmp, lun, ncol
C
C Gray scale
DATA rint1/0., 1./
DATA gint1/0., 1./
DATA bint1/0., 1./
DATA rnci1/0., 1./
C
C Original Cambridge LUT
DATA rint2/0., 0., 1., 1./
DATA gint2/0., 1., 0., 1./
DATA bint2/1., 0., 0., 1./
DATA rnci2/0., .3333333, .6666666, 1.0/
C
C Color spectrum LUT
DATA rint3/0., .30, .20, .05, .70, .90, 1./
DATA gint3/0., .00, .20, .60, .70, .13, 1./
DATA bint3/0., .30, .95, .05, .05, .13, 1./
DATA rnci3/0., .167, .333, .500, .667, .833, 1./
C
11 FORMAT(A)
C
C Check to see if color table should be inverted.
IF ( Ctable(1:1).EQ.'-' ) THEN
is = 2
invert = 1
ELSE
is = 1
invert = 0
END IF
C
ncol = 0
itab = NINT(FPNUM(Ctable(is:),Ltable-is+1,ier))
IF ( ier.EQ.0 ) THEN
IF ( itab.EQ.1 ) THEN
ncol = 2
DO i=1,ncol
rnci(i) = rnci1(i)
rint(i) = rint1(i)
gint(i) = gint1(i)
bint(i) = bint1(i)
END DO
ELSE IF ( itab.EQ.2 ) THEN
ncol = 4
DO i=1,ncol
rnci(i) = rnci2(i)
rint(i) = rint2(i)
gint(i) = gint2(i)
bint(i) = bint2(i)
END DO
ELSE IF ( itab.EQ.3 ) THEN
ncol = 7
DO i=1,ncol
rnci(i) = rnci3(i)
rint(i) = rint3(i)
gint(i) = gint3(i)
bint(i) = bint3(i)
END DO
END IF
ELSE
CALL GETLUN(lun)
cnam = Ctable(is:)
CALL XTEND(cnam, 'ct')
CALL OPENWR(lun,cnam,'OLD',' ',' ',0,1,ier)
IF ( ier.NE.0 ) THEN
C Search user defined directory (if it exists)
CALL TRLOG('MY_XCOMS',8,ctmp,ltmp)
IF ( ltmp.GT.0 ) THEN
ctmp(ltmp+1:) = cnam
CALL OPENWR(lun,ctmp,'OLD',' ',' ',0,1,ier)
END IF
IF ( ier.NE.0 ) THEN
C Search system directory
ctmp = cnam
CALL PTEND('$XANADU','xanlib/xcoms',ctmp)
CALL OPENWR(lun,ctmp,'OLD',' ',' ',0,1,ier)
IF ( ier.NE.0 ) THEN
ltmp = LENACT(ctmp)
WRITE(*,*) 'Unable to open file=',ctmp(:ltmp)
GOTO 340
END IF
END IF
END IF
310 CONTINUE
READ(lun,11,IOSTAT=ios) cbuf
IF ( ios.NE.0 ) GOTO 340
lbuf = LENACT(cbuf)
C Ignore blank lines, or comment linew
IF ( lbuf.LE.0 .OR. cbuf(1:1).EQ.'!' ) GOTO 310
ncol = ncol + 1
kp = 0
CALL ALF(cbuf, lbuf, kp, ctmp, ltmp)
rnci(ncol) = FPNUM(ctmp, ltmp, ier)
CALL ALF(cbuf, lbuf, kp, ctmp, ltmp)
rint(ncol) = FPNUM(ctmp, ltmp, ier)
CALL ALF(cbuf, lbuf, kp, ctmp, ltmp)
gint(ncol) = FPNUM(ctmp, ltmp, ier)
CALL ALF(cbuf, lbuf, kp, ctmp, ltmp)
bint(ncol) = FPNUM(ctmp, ltmp, ier)
IF ( ncol.LT.MXCOL ) GOTO 310
340 CONTINUE
C WRITE(*,*) 'Read',ncol,' colors.'
CLOSE(UNIT=lun)
CALL FRELUN(lun)
END IF
C
IF ( ncol.NE.0 ) THEN
C Got a valid color table, invert it if needed.
IF ( invert.NE.0 ) THEN
DO i=1,ncol/2
tmp = rnci(i)
rnci(i) = 1.0 - rnci(ncol+1-i)
rnci(ncol+1-i) = 1.0 - tmp
tmp = rint(i)
rint(i) = rint(ncol+1-i)
rint(ncol+1-i) = tmp
tmp = gint(i)
gint(i) = gint(ncol+1-i)
gint(ncol+1-i) = tmp
tmp = bint(i)
bint(i) = bint(ncol+1-i)
bint(ncol+1-i) = tmp
END DO
END IF
C Load table.
CALL PGCTAB(rnci,rint,gint,bint,ncol,1.0,0.5)
ELSE
C User gave an invalid color table, give him some help.
WRITE(*,*) 'Builtin color tables are:'
WRITE(*,*) ' 1 - Grayscale'
WRITE(*,*) ' 2 - Black, Blue, Green, Red, White'
WRITE(*,*) ' 3 - Black, Magenta, Blue, Yellow, Green, '//
& 'Orange, Red, White'
END IF
RETURN
END
fv5.5/tcltk/plt/pltcur.f 0000644 0002207 0000036 00000002445 13224715127 014126 0 ustar birby lhea SUBROUTINE PLTCUR(WINLOC, BOXVP, XYSCAL, MXWIN, LOGX, LOGY,
: IACTW, Iwadj, IWNUM, VX, VY, WX, WY, CHR)
INTEGER MXWIN, LOGX(*), LOGY(*), IACTW(*), Iwadj(*)
INTEGER IWNUM
REAL BOXVP(4,*), WINLOC(4,*), XYSCAL(4,*)
REAL VX, VY, WX, WY
CHARACTER CHR
C---
C Wrapup for PGCURSE.
C---
C IWNUM O The window containing the cursor position.
C VX,VY O The cursor position in NDC.
C WX,WY O The cursor position in window coordinates for IWNUM.
C---
INTEGER I
C---
CALL PLTSVW(BOXVP, WINLOC, XYSCAL, LOGX, LOGY, Iwadj, 0)
CALL PGCURSE( VX, VY, CHR)
DO 120 I=1,MXWIN
IF(IACTW(I).GT.0) THEN
IF(WINLOC(1,I).LE.VX .AND. VX.LE.WINLOC(3,I) .AND.
: WINLOC(2,I).LE.VY .AND. VY.LE.WINLOC(4,I)) THEN
IWNUM=I
GOTO 130
END IF
END IF
120 CONTINUE
WX=VX
WY=VY
RETURN
C---
C The window has been identified, so convert to window coordinates.
130 CONTINUE
CALL PLTSVW(BOXVP, WINLOC, XYSCAL, LOGX, LOGY, Iwadj, IWNUM)
CALL PLTVTW(VX, VY, WX, WY)
IF(LOGX(IWNUM).NE.0 .AND. WX.LT.32.) THEN
WX=10.**WX
END IF
IF(LOGY(IWNUM).NE.0 .AND. WY.LT.32.) THEN
WY=10.**WY
END IF
RETURN
END
fv5.5/tcltk/plt/plthis.f 0000644 0002207 0000036 00000000503 13224715127 014111 0 ustar birby lhea SUBROUTINE PLTHIS(A,IDIM,JDIM,I1,I2,J1,J2,BLACK,WHITE)
INTEGER IDIM, JDIM, I1, I2, J1, J2
REAL A(IDIM,JDIM)
REAL BLACK, WHITE
C---
C Dummy routine, waiting for PGPLOT to add needed routines.
C-----------------------------------------------------------------------
RETURN
END
fv5.5/tcltk/plt/pltlab.f 0000644 0002207 0000036 00000007010 13224715127 014064 0 ustar birby lhea SUBROUTINE PLTLAB(LUN, ICLAB, CLAB, FLAB, ILAB)
INTEGER LUN, ICLAB
CHARACTER CLAB(*)*(*)
REAL FLAB(7,*)
INTEGER ILAB(7,*)
C---
C PLT support routine to write out commands of the form LA # 'test'
C---
C LUN I
C ICLAB I
C CLAB I
C FLAB I
C ILAB I
C---
C 1990-Mar-01 - New routine [AFT]
C---
INTEGER LENACT
C
CHARACTER CBUF*132
CHARACTER CHPOS(3)*3, CVPOS(5)*3
INTEGER ISAV, LBUF, LTMP
DATA CHPOS/'Lef','Cen','Rig'/
DATA CVPOS/'Top','Cap','Hal','Bas','Bot'/
C---
11 FORMAT(A)
C---
IF(ILAB(1,ICLAB).NE.0) THEN
CBUF = 'LAB '
LBUF = 5
CALL CRAMI(ICLAB,CBUF,LBUF)
LBUF = LBUF+1
ISAV = LBUF
IF(ILAB(4,ICLAB).NE.1) THEN
CBUF(LBUF+1:LBUF+3) = 'COL'
LBUF = LBUF+4
CALL CRAMI(ILAB(4,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
END IF
IF(FLAB(4,ICLAB).NE.1.0) THEN
CBUF(LBUF+1:LBUF+2) = 'CS'
LBUF = LBUF+3
CALL CRAMF(FLAB(4,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
END IF
IF( Ilab(7,iclab).GT.0 ) THEN
CBUF(LBUF+1:LBUF+2) = 'TO'
LBUF = LBUF+3
CALL CRAMF(FLAB(5,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
CALL CRAMF(FLAB(6,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
ELSE IF(FLAB(6,ICLAB).GT.0.0) THEN
CBUF(LBUF+1:LBUF+3) = 'LIN'
LBUF = LBUF+4
CALL CRAMF(FLAB(5,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
IF ( ABS(FLAB(6,ICLAB)-0.08).GT.0.00001 ) THEN
CALL CRAMF(FLAB(6,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
END IF
END IF
IF(ILAB(5,ICLAB).NE.1) THEN
CBUF(LBUF+1:LBUF+2) = 'LS'
LBUF = LBUF+3
CALL CRAMI(ILAB(5,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
END IF
IF(ILAB(6,ICLAB).GE.0) THEN
CBUF(LBUF+1:LBUF+3) = 'MAR'
LBUF = LBUF+4
CALL CRAMI(ILAB(6,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
IF(FLAB(7,ICLAB).NE.1.0) THEN
CBUF(LBUF+1:LBUF+4) = 'MSIZ'
LBUF = LBUF+5
CALL CRAMF(FLAB(7,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
END IF
END IF
IF(FLAB(3,ICLAB).NE.0.) THEN
CBUF(LBUF+1:LBUF+3) = 'ROT'
LBUF = LBUF+4
CALL CRAMF(FLAB(3,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
END IF
C---
C Add Center and Justification to end of string, so Line and Mark
C will not over-ride these settings.
IF(ILAB(3,ICLAB).NE.3) THEN
CBUF(LBUF+1:LBUF+7) = 'CEN '//CVPOS(ILAB(3,ICLAB))
LBUF = LBUF+8
END IF
IF(ILAB(2,ICLAB).NE.2) THEN
CBUF(LBUF+1:LBUF+7) = 'JUS '//CHPOS(ILAB(2,ICLAB))
LBUF = LBUF+8
END IF
IF(LBUF.GT.ISAV) WRITE(LUN,11) CBUF(:LBUF-1)
C---
C Always write a line of the form, LAB # POS # # "label"
CBUF = 'LAB '
LBUF = 5
CALL CRAMI(ICLAB,CBUF,LBUF)
LBUF = LBUF+1
IF(ILAB(1,ICLAB).LT.0) THEN
CBUF(LBUF+1:LBUF+3) = 'VIE'
ELSE
CBUF(LBUF+1:LBUF+3) = 'POS'
END IF
LBUF = LBUF+4
CALL CRAMF(FLAB(1,ICLAB), CBUF, LBUF)
LBUF = LBUF+1
CALL CRAMF(FLAB(2,ICLAB), CBUF, LBUF)
LTMP = MAX(LENACT(CLAB(ICLAB)), 1)
WRITE(LUN,161) CBUF(:LBUF),CLAB(ICLAB)(:LTMP)
161 FORMAT(A,' "',A,'"')
END IF
RETURN
END
fv5.5/tcltk/plt/pltskp.f 0000644 0002207 0000036 00000005447 13224715127 014137 0 ustar birby lhea SUBROUTINE PLTSKP(Y, Iery, Mxrow, Npts, Nvec, Mxgrp,
& Iskip, Ixvec, Ngroup, Igrpos, Ipyer, Ipwin)
INTEGER Iery(*), Mxrow, Npts, Nvec, Mxgrp, Iskip
INTEGER Ixvec, Igrpos(3,*), Ipyer(*), Ipwin(*), Ngroup
REAL Y(*)
C---
C Initialize the Igrpos array when using SKIP.
C---
C Y I Main data array
C Iery I
C Mxrow I
C Npts I
C Nvec I
C Mxgrp I
C Iskip I
C Ixvec I
C Ngroup I/O Total number of PLT groups
C Igrpos(1,*) O The y-coordinate offset
C Igrpos(2,*) O Number of points in current group
C Igrpos(3,*) O Original vector number for the Y data
C Ipyer O
C Ipwin O
C---
C 1990-Feb-28 - Extracted from PLT - [AFT]
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER IOFSET
C---
REAL tmp
INTEGER i, icnt, igrp, ioff, itmp, ivec, ixoff, iytmp
INTEGER lasgrp, nno
C---
C Mark any previously defined groups as undefined.
DO igrp=1,Ngroup
igrpos(1,igrp) = -1
IF ( Ipwin(igrp).GT.0 ) THEN
Ipwin(igrp)=-ABS(Ipwin(igrp))
END IF
END DO
C
ixoff= IOFSET(Ixvec, Iery, Nvec, Mxrow)
ioff = IOFSET( 1, Iery, Nvec, Mxrow)
nno = Iskip
icnt = Iskip
lasgrp= 1
Ngroup= 0
DO i=1,Npts
icnt=icnt+1
tmp = Y(ixoff+i)
IF ( tmp.EQ.NO ) THEN
nno=nno+1
ELSE
IF ( nno.GE.Iskip ) THEN
C Load number of points for previous set of groups. Don't include the
C ending NO data flags counted Iskip times in the count.
DO igrp=lasgrp,Ngroup
Igrpos(2,igrp)=icnt-nno-1
END DO
lasgrp = Ngroup+1
icnt = 1
iytmp = ioff+I-1
DO ivec=1,Nvec
IF ( ivec.NE.Ixvec ) THEN
Ngroup = MIN(Ngroup+1,Mxgrp)
CALL PLTXCN(Ngroup, 1, 0)
itmp = iofset(ixvec, Iery, ixvec, Mxrow)+i-1
CALL PLTXCG(Ngroup,1,ixvec,itmp,iery)
Igrpos(1,Ngroup) = iytmp
Igrpos(3,Ngroup) = ivec
Ipyer(Ngroup) = MIN(Iery(ivec), 1)
END IF
iytmp = iytmp+Mxrow
IF(Iery(ivec).GT.0) iytmp = iytmp+Iery(ivec)*Mxrow
END DO
END IF
nno = 0
END IF
END DO
C---
DO igrp=lasgrp,Ngroup
Igrpos(2,igrp) = icnt-nno
END DO
C---
C Make sure any newly defined groups are assigned plot windows.
DO igrp=1,Ngroup
IF ( Igrpos(1,igrp).GE.0 ) THEN
IF ( Ipwin(igrp).LT.0 ) THEN
Ipwin(igrp)=ABS(Ipwin(igrp))
ELSE
Ipwin(igrp)=1
END IF
END IF
END DO
C
RETURN
END
fv5.5/tcltk/plt/pltsub.f 0000644 0002207 0000036 00000004117 13224715127 014124 0 ustar birby lhea C--- PLTSUB.FOR Contains high level routines called by PLT.
C IOFSET
C PLTGAP
C---
INTEGER FUNCTION IOFSET(Ivec, Iery, Ngroup, Mxrow)
INTEGER Ivec, Iery(*), Ngroup, Mxrow
C---
C Compute offset into the Y data array
C---
C Ivec I
C Iery I
C Ngroup I
C Mxrow I
C---
C AFT
C---
INTEGER i, ix, loc
C---
ix=MIN(MAX(1,Ivec),Ngroup)
loc=0
DO i=1,Ngroup
IF ( i.EQ.ix ) THEN
IOFSET=loc
RETURN
END IF
loc=loc+mxrow
IF ( Iery(i).GT.0 ) loc=loc+Mxrow*Iery(i)
END DO
WRITE(*,*) 'ERROR--IOFSET, Unable to find vector',Ivec
IOFSET = 0
RETURN
END
C*********
SUBROUTINE PLTGAP(Rmini, Rmaxi, Space, Log, Rmino, Rmaxo)
REAL Rmini, Rmaxi, Space, Rmino, Rmaxo
INTEGER Log
C---
C PLT subroutine to add in the user selected whitespace to the
C data min/max for the plot boundaries
C---
C Rmini I Min
C Rmaxi I Max
C Space I Size of the whiteSpace
C Log I Flag, If not zero, then the spacing is Log
C Rmino O Min
C Rmaxo O Max
C---
C 8-Oct-1988 - rashafer
C---
REAL tmpmin, tmpmax, delta
C
IF (Space.EQ.0) THEN
Rmino = Rmini
Rmaxo = Rmaxi
RETURN
END IF
tmpmin = Rmini
tmpmax = Rmaxi
IF ( (Log.NE.0).AND.(tmpmin.GT.0.).AND.(tmpmax.GT.0.) ) THEN
C** Its log spacing to be done
delta = tmpmax / tmpmin
IF ( delta .LE. 1.) THEN
C** they're degenerate, so just allow a single decade
delta = 3.4
ELSE
delta = MAX( delta ** ABS(Space), SQRT(10.5/delta) )
END IF
Rmino = tmpmin / delta
Rmaxo = tmpmax * delta
ELSE
C** linear spacing
delta = tmpmax - tmpmin
IF ( delta .LE. 0.) THEN
IF (tmpmin .EQ. 0.) THEN
delta = 0.5
ELSE
delta = Space*ABS(tmpmin)
END IF
ELSE
delta = delta*Space
END IF
Rmino = tmpmin - delta
Rmaxo = tmpmax + delta
END IF
RETURN
END
fv5.5/tcltk/plt/pltxc.f 0000644 0002207 0000036 00000015537 13224715127 013755 0 ustar birby lhea SUBROUTINE PLTXCC(Yray, Ipos, Igrp, Xc, Ndim, Iyoff)
REAL Yray(*), Xc(*)
INTEGER Ipos, Igrp, Ndim, Iyoff
C Entry PLTXCD
INTEGER Iold, Inew
C Entry PLTXCE
REAL Xm, Xp
C Entry PLTXCG
INTEGER Idim, Ixveci, Ixoff, Iery(*)
C Entry PLTXCI
INTEGER Mxrowi
C Entry PLTXCL
REAL Offi, Slopi
C Entry PLTXCN
INTEGER Ndimi, Npci
C Entry PLTXCO
REAL Xoffi
C Entry PLTXCP
INTEGER Ipxei
C---
C The X-coordinate "object". This subroutine stores all the internal
C data needed to compute the x-coordinate of data point Ipos in plot
C group with Igrp. To allow for 2D (or higher), Xc is an array,
C with Xc(1) the traditional X position, Xc(2) Y, etc. as needed.
C---
C Yray I The master data array
C Igrp I The plot group to compute the Xc array for
C Ipos I The index into the plt group
C Xc O The X coordinates
C---
C 2000-08-10 - all the pltxcp entry - [AFT]
C 1998-10-05 - created from FNX - AFT
C---
REAL NO
PARAMETER (NO=-1.2E-34)
INTEGER MXDIM, MXGRP
PARAMETER (MXDIM=2, MXGRP=500)
C
REAL slop(MXDIM, MXGRP), off(MXDIM, MXGRP)
SAVE slop, off
REAL slop0(MXDIM, MXGRP), off0(MXDIM, MXGRP)
SAVE slop0, off0
REAL xoff(MXDIM, MXGRP)
SAVE xoff
INTEGER ierx(MXDIM, MXGRP), ipxer(MXDIM, MXGRP)
SAVE ierx, ipxer
INTEGER ixbeg(MXDIM, MXGRP), ixvec(MXDIM, MXGRP)
SAVE ixbeg, ixvec
INTEGER ndims(MXGRP), new(MXDIM, MXGRP), npc(MXGRP)
SAVE ndims, new, npc
INTEGER mxrow
SAVE mxrow
INTEGER icolm1, id, ig, irow
C---
Ndim = Ndims(Igrp)
IF ( Ndims(Igrp).GT.1 ) THEN
C icolm1 is the column number minus 1
icolm1 = (Ipos - 1)/npc(Igrp)
irow = Ipos - icolm1*npc(Igrp)
Xc(2)=off(2,Igrp)+icolm1*slop(2,Igrp)+xoff(2,Igrp)
iyoff = irow + mxrow*icolm1
ELSE
Xc(2) = 0.0
irow = Ipos
Iyoff = irow
END IF
IF ( ixbeg(1,Igrp).LT.0 ) THEN
Xc(1)=off(1,Igrp)+(irow-1)*slop(1,Igrp)+xoff(1,Igrp)
ELSE
Xc(1)=Yray(ixbeg(1,Igrp)+irow)+xoff(1,Igrp)
END IF
RETURN
C***
ENTRY PLTXCD(Iold, Inew)
C Duplicate the X coordinate of an existing group
DO id=1,MXDIM
slop(id, Inew) = slop(id, Iold)
off(id, Inew) = off(id, Iold)
xoff(id, Inew) = xoff(id, Iold)
ierx(id, Inew) = ierx(id, Iold)
ipxer(id, Inew) = ipxer(id, Iold)
ixbeg(id, Inew) = ixbeg(id, Iold)
new(id, Inew) = new(id, Iold)
END DO
ndims(Inew) = ndims(Iold)
npc(Inew) = npc(Iold)
RETURN
C***
ENTRY PLTXCE(Yray, Ipos, Igrp, Idim, Xm, Xp)
C Return the X error
IF ( ipxer(Idim,Igrp).EQ.-2 ) THEN
Xp = 1+SQRT(0.75+ABS(Yray(ixbeg(Idim,Igrp)+Ipos)))
Xm = -Xp
ELSE IF ( ipxer(Idim,Igrp).EQ.-1 ) THEN
Xp = SQRT(ABS(Yray(ixbeg(Idim,Igrp)+Ipos)))
Xm = -Xp
ELSE IF ( ipxer(Idim,Igrp).EQ.0 ) THEN
Xp = 0.0
Xm = 0.0
ELSE
IF ( ixbeg(Idim,Igrp).LT.0 ) THEN
C XAx LIN is easy
Xp = ABS(slop(Idim,Igrp))/2.
Xm = -Xp
ELSE
C This uses XAx #
C%%% fails for 2d arrays, i.e., YAx #
IF ( Ierx(idim, Igrp).EQ.1 ) THEN
Xp = Yray(Mxrow+ixbeg(Idim,Igrp)+Ipos)
Xm = -Xp
ELSE IF ( Ierx(idim, Igrp).EQ.2 ) THEN
Xp = Yray( Mxrow+ixbeg(Idim,Igrp)+Ipos)
Xm = Yray(2*Mxrow+ixbeg(Idim,Igrp)+Ipos)
ELSE
Xp = 0.0
Xm = 0.0
END IF
END IF
END IF
RETURN
C***
ENTRY PLTXCG(Igrp, Idim, Ixveci, Ixoff, Iery)
C Implement XAX # . The first X coordinate is at Yray(Ixbeg+1).
C---
C Trap coding errors....
IF ( Ixveci.LE.0 ) THEN
WRITE(*,*) 'PLTXCG--ixveci=',ixveci
STOP
END IF
IF ( Idim.GT.MXDIM ) THEN
WRITE(*,*) 'PLTXCG--Idim,MXDIM=',Idim,MXDIM
STOP
END IF
IF ( Igrp.GT.MXGRP ) THEN
WRITE(*,*) 'PLTXCG--Igrp,MXGRP=',ixveci,MXGRP
STOP
END IF
C
ixvec(Idim, Igrp) = Ixveci
ierx(Idim, Igrp) = Iery(Ixveci)
ipxer(Idim, Igrp) = 1
xoff(Idim, Igrp) = 0.
ixbeg(Idim, Igrp) = Ixoff
RETURN
C***
ENTRY PLTXCI(Mxrowi)
C Initialize the "new" array. This allows pltxc to remember the first
C XAX LIN numbers, hence the user does not need to remember this. Why?
C Because, the first XAX LIN is often defined in the *.qdp, *.pco, or
C otherwise in the calling program.
mxrow = Mxrowi
DO ig=1, MXGRP
DO id=1,MXDIM
new(id, ig) = 1
C Default XAX LIN 1 1
ixbeg(id, ig) = -1
off(id, ig) = 1.0
slop(id, ig) = 1.0
off0(id, ig) = 1.0
slop0(id, ig) = 1.0
C No "extra" offset
xoff(id, ig) = 0.0
END DO
END DO
RETURN
C***
ENTRY PLTXCL(Igrp, Idim, Offi, Slopi)
C Implement XAX/YAX LIN
ixbeg(Idim, Igrp) = -1
IF ( Offi .EQ.NO .AND. Slopi.EQ.NO ) THEN
C Both values are NO, then restore the first set of numbers.
off(Idim, Igrp) = Off0(Idim, Igrp)
slop(Idim, Igrp) = Slop0(Idim, Igrp)
ELSE
IF ( Offi .NE.NO ) off(Idim, Igrp) = Offi
IF ( Slopi.NE.NO ) slop(Idim, Igrp) = Slopi
C An increment of zero can cause problems later. So fudge value here.
IF ( slop(Idim, Igrp).EQ.0. ) slop(Idim, Igrp) = 1.
IF ( new(Idim,Igrp).NE.0 ) THEN
new(idim, Igrp) = 0
off0(Idim, Igrp) = off(Idim, Igrp)
slop0(Idim, Igrp) = slop(Idim, Igrp)
END IF
END IF
xoff(Idim, Igrp) = 0.
ipxer(Idim, Igrp) = 1
RETURN
C***
ENTRY PLTXCN(Igrp, Ndimi, Npci)
C Set number of dimensions
IF ( Ndimi.GT.MXDIM ) THEN
WRITE(*,*) 'PLTXCN--Attempt to create', Ndimi,
& ' dimensional array.'
WRITE(*,*) 'PLTXCN--Maximum allowed is',MXDIM, '.'
STOP
ELSE IF ( Igrp.GT.MXGRP ) THEN
WRITE(*,*) 'PLTXCN--Attempt to create group number', Igrp
WRITE(*,*) 'PLTXCN--Maximum allowed group is',MXGRP, '.'
STOP
END IF
ndims(Igrp) = Ndimi
npc(Igrp) = Npci
IF ( ndims(Igrp).GT.1 .AND. npc(Igrp).EQ.0 ) THEN
WRITE(*,*) 'PLTXCN--Npc must be non-zero for 2D data!'
STOP
END IF
RETURN
C***
ENTRY PLTXCO(Igrp, Idim, Xoffi)
C Implement XAX OFF command
xoff(Idim, Igrp) = Xoffi
RETURN
C***
ENTRY PLTXCP(Igrp, Idim, Ipxei)
C Implement ERR X on/off/sqrt/ger
ipxer(Idim, Igrp) = Ipxei
RETURN
C***
ENTRY PLTXCQ(Igrp, Idim, Ipxei)
C Query plot X error status.
Ipxei = ipxer(Idim, Igrp)
RETURN
END
fv5.5/tcltk/plt/ptbuf.f 0000644 0002207 0000036 00000002140 13224715127 013725 0 ustar birby lhea SUBROUTINE PTBUF(Cline, Lline)
CHARACTER Cline*(*)
INTEGER Lline
C---
C This routine writes a single line to the current output device.
C If line editing is activated, then the line editing IO routines
C are used.
C---
C Cline I The line to be written.
C Lline I The number of valid characters in Cline. Lline=-1
C -causes LENACT to determine the number of valid characters.
C---
C 2002-May-23 - Adapted from ttwrt [AFT]
C---
INCLUDE 'edicmn.inc'
INTEGER ILF
PARAMETER (ILF = 10)
INTEGER ICR
PARAMETER (ICR = 13)
INTEGER LENACT
C
REAL rbuf(1)
INTEGER itmp
C
itmp=Lline
IF ( itmp.LT.0 ) itmp=LENACT(Cline)
IF ( ICEDIT.EQ.0 ) THEN
WRITE(*,111) Cline(:itmp)
111 FORMAT(A)
ELSE
IF ( IFTYPE.LT.0 ) CALL PUTSTR(CHAR(ICR)//CHAR(ILF), 2)
CALL PUTSTR(Cline, itmp)
CALL PUTSTR(CHAR(ICR), 1)
IF ( IFTYPE.GT.0 ) CALL PUTSTR(CHAR(ILF),1)
CALL FLUSH(6)
END IF
C
C And log
CALL LOGGER(5,rbuf,0,Cline,itmp)
RETURN
END
fv5.5/tcltk/plt/rdqdp.f 0000644 0002207 0000036 00000016426 13224715127 013733 0 ustar birby lhea SUBROUTINE RDQDP(Ichat, Lunin, Cnam, Yray, Mxpts, Iery, Mxvec,
: Nrow, Npts, Nvec, Cmd, Mxcmd, Ncmd, Ier)
INTEGER Mxpts, Mxvec, Mxcmd
CHARACTER Cnam*(*), Cmd(Mxcmd)*(*)
REAL Yray(Mxpts)
INTEGER Iery(Mxvec)
INTEGER Ichat, Lunin, Nrow, Npts, Nvec, Ncmd, Ier
C---
C Opens and reads a QDP file.
C---
C Ichat I >0 print row/col info, >10 means print comment lines,
C =-1 do an HTML decode
C Lunin I <>0 means file already open on lun.
C Cnam I/O File name.
C Yray O The data array
C Mxpts I The actual size of the Y array.
C Iery O The PLT error flag array
C Mxvec I The actual size of the Iery array
C Nrow O Maximum number of rows that the file could contain.
C Npts,Nvec O Needed by PLT
C Cmd O Command array (Mxcmd input dimension).
C Ncmd O Number of commands read
C Ier O =-1 if user entered EOF, =0 file read, =1 no file read.
C---
C 1989-Jul-31 - Changed calling sequence to allow RDQDP to optimize storage.
C 1989-Feb-13 - Latest mod [AFT]
C---
REAL FPNUM
INTEGER ISNUM, LENACT
C
CHARACTER cbuf*1024
CHARACTER ctok*128, ctmp
REAL value
INTEGER i, icon, ierf, icol, ios, itmp, ix
INTEGER kp, lbuf, Lnam, ltok, lun, ncol
C---
11 FORMAT(A)
C---
Nvec=0
C- Open file if needed.
lun=Lunin
IF ( lun.EQ.0 ) THEN
100 IF ( Cnam.EQ.' ' ) THEN
CALL GTBUF('QDP file name:',Ier)
IF ( Ier.LT.0 ) GOTO 900
CALL GTCHAR(Cnam,Lnam)
END IF
IF ( Cnam.EQ.' ' ) THEN
Ier=1
GOTO 950
END IF
130 CALL XTEND(Cnam,'qdp')
IF ( lun.EQ.0 ) THEN
CALL GETlun(lun)
ELSE
CLOSE(UNIT=lun)
END IF
CALL OPENWR(lun,Cnam,'OLD',' ',' ',0,1,ios)
IF ( ios.NE.0 ) THEN
Cnam=' '
GOTO 100
END IF
END IF
INQUIRE(UNIT=lun,NAME=Cnam)
C---
Ier=0
DO i=1,Mxvec
Iery(i)=0
END DO
Ncmd=0
IF ( Ichat.GE.0 .AND. Ncmd.LT.Mxcmd ) THEN
Ncmd=Ncmd+1
Cmd(Ncmd)='LA F '//Cnam
END IF
Npts=0
C---
200 CONTINUE
READ(lun,11,END=800) cbuf
lbuf=LENACT(cbuf)
C Skip blank lines.
IF ( lbuf.EQ.0 ) GOTO 200
IF ( ichat.EQ.-1 ) CALL HDECOD(cbuf, lbuf)
C---
kp=0
CALL ALFSKS(cbuf, lbuf, kp)
IF ( cbuf(kp+1:kp+1).EQ.'!' ) THEN
C Echo all comment lines (if chatter on).
IF ( Ichat.GT.10 .AND. lbuf.GT.0) WRITE(*,221) cbuf(:lbuf )
221 FORMAT(1X,A)
GOTO 200
END IF
ctmp = cbuf(kp+1:kp+1)
CALL ALF(cbuf,lbuf,kp,ctok,ltok)
C Special treatment for a single number and a continuation mark as
C the trailing minus would causes ISNUM to return not a number.
IF ( ctok(ltok:ltok).EQ.'-' ) THEN
itmp=ltok-1
ELSE
itmp=ltok
END IF
IF ( ISNUM(ctok,ltok).NE.0 .AND. ctmp.NE.'"' ) GOTO 300
CALL UPC(ctok)
IF ( ctok(1:4).EQ.'READ' ) THEN
CALL ALF(cbuf,lbuf,kp,ctok,ltok)
CALL UPC(ctok)
ierf=0
IF ( ctok(1:1).EQ.'S' ) ierf=1
IF ( ctok(1:1).EQ.'T' ) ierf=2
IF ( ierf.EQ.0 ) GOTO 200
C---
230 CALL ALF(cbuf,lbuf,kp,ctok,ltok)
IF ( ltok.LE.0 ) GOTO 200
ix=FPNUM(ctok,ltok,Ier)
IF ( ix.LT.0 .OR. ix.GT.Mxvec ) GOTO 230
Iery(ix)=ierf
GOTO 230
ELSE
IF ( Ncmd.LT.Mxcmd ) Ncmd=Ncmd+1
IF ( lbuf.GT.0) Cmd(Ncmd)=cbuf(:lbuf )
END IF
GOTO 200
C---
C Read a data line.
300 CONTINUE
IF ( lbuf.LE.0 ) THEN
itmp=0
ELSE
itmp=INDEX(cbuf(:lbuf),'!')
END IF
IF ( itmp.GT.1) lbuf=LENACT(cbuf(:itmp-1) )
IF ( lbuf.GT.0 .AND. cbuf(lbuf:lbuf).EQ.'-' ) THEN
icon=1
lbuf=lbuf-1
ELSE
icon=0
END IF
C If this is the first data point then calculate Nvec, Nrow, and ncol.
C Ensure that neither Y nor Iery arrays will overflow.
IF ( Npts.EQ.0 ) THEN
C First we calculate the number of tokens on the line
kp=0
icol=0
310 CONTINUE
CALL RDCONR(lun,Ichat,icon,cbuf,lbuf,kp,ctok,ltok,value)
icol=icol+1
Yray(icol)=value
IF ( kp.LT.lbuf ) GOTO 310
C
C Next we match tokens to vectors. This is done here because user
C may not have forgotten to include an error on a vector in which
C an error is expected from an 'READ xERR' command.
ncol=0
330 CONTINUE
Nvec=Nvec+1
ncol=ncol+1
IF ( Iery(Nvec).EQ.1 ) THEN
C Skip one column for symmetric errors
ncol=ncol+1
ELSE IF ( Iery(Nvec).EQ.2 ) THEN
C or two columns for two-sided errors
ncol=ncol+2
END IF
IF ( ncol.LT.icol .AND. Nvec.LT.Mxvec ) GOTO 330
C
Nrow=Mxpts/ncol
IF ( Ichat.GT.0 ) THEN
WRITE(*,351) ncol, Nvec, Nrow
351 FORMAT(/,' Reading',I5,' columns,',I5,' vectors.',
: ' Maximum number of rows is',I8,'.',/)
END IF
C
C We can now move the first row to the proper location in the Y array.
C This is done from the top down to avoid the possibility of trashing
C a number before moving it.
IF ( ncol.GT.1 ) THEN
itmp=Nrow*(ncol-1)+1
DO i=ncol,2,-1
Yray(itmp)=Yray(i)
Yray(i)=0.
itmp=itmp-Nrow
END DO
END IF
Npts=1
ELSE
C
IF ( Npts.GE.Nrow ) THEN
WRITE(*,*) 'RDQDP--Too many lines in file.'
GOTO 800
END IF
kp=0
Npts=Npts+1
itmp=Npts
DO icol=1, ncol
CALL RDCONR(lun,Ichat,icon,cbuf,lbuf,kp,ctok,ltok,value)
Yray(itmp)=value
itmp=itmp+Nrow
END DO
END IF
GOTO 200
C---
C No error
800 CONTINUE
Ier=0
GOTO 950
C---
C Error
900 CONTINUE
Ier=-1
C Common exit
950 CONTINUE
IF ( lun.GT.0 ) THEN
CLOSE(UNIT=lun)
CALL FRElun(lun)
END IF
RETURN
END
C*********
SUBROUTINE RDCONR(Lun,Ichat,Icon,Cbuf,Lbuf,Kp,Ctok,Ltok,Value)
CHARACTER Cbuf*(*), Ctok*(*)
INTEGER Lun, Ichat, Icon, Lbuf, Kp, Ltok
REAL Value
C---
C Read with continuation a real number.
C---
C Lun I The open unit being read
C Ichat I =-1 to hdecod lines as they are read
C Icon I/O
C Cbuf I/O
C Lbuf I/O
C Kp I/O
C Ctok I/O
C Ltok I/O
C Value O
C---
REAL FPNUM
INTEGER LENACT
C
INTEGER ier, itmp
C---
11 FORMAT(A)
C---
CALL ALF(Cbuf, Lbuf, Kp, Ctok, Ltok)
Value = FPNUM(Ctok, Ltok, ier)
C
100 CONTINUE
IF ( Kp.GE.Lbuf .AND. Icon.GT.0 ) THEN
READ(Lun,11,END=800) Cbuf
Lbuf=LENACT(Cbuf)
IF ( ichat.EQ.-1 ) CALL HDECOD(Cbuf, Lbuf)
IF ( Lbuf.LE.0 ) THEN
itmp=0
ELSE
itmp=INDEX(Cbuf(:Lbuf),'!')
END IF
IF ( itmp.GT.1) Lbuf=LENACT(Cbuf(:itmp-1) )
IF ( Lbuf.GT.0 .AND. Cbuf(Lbuf:Lbuf).EQ.'-' ) THEN
Icon=1
Lbuf=Lbuf-1
ELSE
Icon=0
END IF
Kp=0
CALL ALFSKS(Cbuf, Lbuf, Kp)
IF ( Kp.GE.Lbuf ) GOTO 100
END IF
C---
800 RETURN
END
fv5.5/tcltk/plt/rescal.f 0000644 0002207 0000036 00000000660 13224715127 014063 0 ustar birby lhea SUBROUTINE RESCAL(CAX, IWNUM, VMIN, VMAX, CTMP, LTMP)
CHARACTER CAX*1, CTMP*(*)
INTEGER IWNUM, LTMP
REAL VMIN, VMAX
C---
CTMP='R '//CAX
LTMP=6
IF(IWNUM.LE.0) THEN
LTMP=LTMP+3
ELSE
CALL CRAMI(IWNUM,CTMP,LTMP)
LTMP=MAX(LTMP+1,6)
END IF
CALL CRAMF(VMIN,CTMP,LTMP)
LTMP=LTMP+1
CALL CRAMF(VMAX,CTMP,LTMP)
RETURN
END
fv5.5/tcltk/plt/set_pgdev.f 0000644 0002207 0000036 00000001253 13224715127 014571 0 ustar birby lhea c
c set_pgdev -- get PGPLOT device name
c
subroutine set_pgdev(indevice)
character*(*) indevice
integer*4 lenstr
integer lenact
character cret*64
integer lret
lenstr = lenact(indevice)
if (indevice(1:1) .eq. '?') then
call pgdev('?')
ccc call trlog ('PGPLOT_DEVICE',13,cret,lret)
call trlog ('PGPLOT_TYPE',11,cret,lret)
indevice(:lret) = cret(:lret)
lenstr = lret
if (indevice(1:1) .eq. ' ') then
indevice(1:1) = '?'
end if
end if
call setenv(indevice)
return
end
fv5.5/tcltk/plt/spline.f 0000644 0002207 0000036 00000015625 13224715127 014113 0 ustar birby lhea C---SPLINE.FOR Contains the FIT Spline model routines.
C---
SUBROUTINE SPLIM(PAR, PLIM, NT, NTERM)
REAL PAR(*), PLIM(3,*)
INTEGER NT, NTERM
C---
C This routine must be called every time a parameter is changed.
C---
C PAR(NTERM) I Contain X and Y locations of the knots.
C PLIM(1,NTERM) I/O <0. means parameter is froozen.
C NKNOT I/O =NTERM/2
C---
C- MXKNOT=MXPAR/2
C---
INTEGER MXKNOT
PARAMETER (MXKNOT=60)
REAL YMIN, YMAX
INTEGER IND, IX
C
REAL Y2, U, XDEL, YDEL
INTEGER NKNOT, IPER
COMMON /SPLCMN/Y2(MXKNOT),U(MXKNOT),XDEL,YDEL,NKNOT,IPER
C---
NKNOT=NTERM/2
IF(NKNOT.GT.MXKNOT) THEN
WRITE(*,101) MXKNOT
101 FORMAT(' SPLIM--Maximum number of knots is=',I6)
NKNOT=MXKNOT
END IF
IF ( NT.EQ.-1 ) THEN
NTERM=2*NKNOT
RETURN
END IF
XDEL=(PAR(NT+NKNOT-1)-PAR(NT))/(20.*NKNOT)
CALL AJUST(XDEL,PAR,PLIM,NT,NKNOT,YMIN,YMAX)
YDEL=(YMAX-YMIN)/500.
IF(YDEL.LE.0.) YDEL=1./500.
IPER=0
IND=NT+2*NKNOT-1
IX=NINT(-PLIM(1,IND))
IF(IX.EQ.NT+NKNOT .AND. PLIM(2,IND).EQ.1.) THEN
C- If first and last Y values are equal, force periodic boundary
C- condition.
IPER=1
END IF
CALL SPLINE(PAR(NT), PAR(NT+NKNOT), Y2, U, NKNOT, IPER)
RETURN
END
C*********
REAL FUNCTION FNSP(X, PAR)
REAL X, PAR(*)
C---
C Evaluate Spline for use in FIT.
C---
INTEGER MXKNOT
PARAMETER (MXKNOT=60)
REAL FNECSP
C
REAL Y2, U, XDEL, YDEL
INTEGER NKNOT, IPER
COMMON /SPLCMN/Y2(MXKNOT),U(MXKNOT),XDEL,YDEL,NKNOT,IPER
C---
FNSP=FNECSP(X, PAR, Y2, NKNOT, IPER)
RETURN
END
C*********
REAL FUNCTION FNECSP(X, PAR, Y2, NKNOT, IPER)
REAL X, PAR(*), Y2(*)
INTEGER NKNOT, IPER
C---
C Evaluates a cubic SPLINE. This routine finds the value of J such
C that PAR(J)<=XTAbout Pow
POW is a curve plotting and image display interface tool written
and distributed by the HEASARC at NASA/GSFC.
Blink Images/Graphs
Within POW, multiple images can be examined for differences by the
common technique of overlaying them and blinking them in rapid
succession. Pow provides two methods for doing this.
Blink Images...
Multiple images can be placed within a single POW graph. This can be
achieved by merging the contents of several graphs into a single one
(via POW's Merge Graphs or Edit Graphs menu items), or, if the data is
part of a 3-D data cube, by using an outside tool (eg, fv) to produce
a graph with each 2-D slice of the cube treated as a separate image.
After the graph containing all the desired images has been created and
selected, select Blink Images from the Edit
menu. A dialog box containing information about the current graph
and controls for the blinking behavior will be displayed. Blink Graphs...
It is not always possible to put all one's images into a single
graph--images may lack a common
coordinate system for automatic alignment--preventing the previous
blinking method from being used. The Blink Graphs menu item
allows individual graphs to be blinked. There is no "natural order"
with which to blink graphs, so the user is presented with a list of
all Available Graphs and must specify which graphs to blink and
in which order. The Add and Insert buttons append to
the end or insert at the current selection point of the Blink
Order list the highlighted graphs from the Available Graphs list.
A graph may appear multiple times in the Blink Order list. The
Delete button removes all highlighted entries from the Blink
Order list. As in the Blink Images method, a slidebar controls the
speed of the blinking. POW and X Colormaps
Generally, if you experience colormap problems, mode 1 is
probably the most robust unless you don't have any pseudocolor
visuals (e.g. a Linux machine running in 16 or 24 bit mode).
The POW Color menu has four parts:
You can interactively change the contrast and brightness of the current image's colortable by dragging the left mouse button across the image.
fv5.5/tcltk/pow/Contours.html 0000644 0002207 0000036 00000006565 13224715127 015165 0 ustar birby lheaSelecting Make Contour Map from the Edit menu brings up a dialog box which allows one to specify how the contour map will be created for the current image in the current graph (indicated by the green bounding box)...
Image Range: Minimum and maximum pixel values of the selected image.
Contour Range: Minimum and maximum values to contour over. The values are initially taken from a "clean" approximation of the min and max pixel values of the image, but the user can change these values to whatever is desired. (Note that the min value need not be less than the max value.)
# Contours: Number of contour levels to produce between the range points. One can either click on the < or > buttons to decrease/increase the number or type in a new number directly.
Scale: Scaling method for interpolating contour levels. The linear method will space the contours over a constant interval from the min and max range. The other two options -- sqrt and log -- do much the same thing but based on the square root or logarithm of the min and max values. These latter options bring out the finer details at the lower contour levels in images with a large dynamic range.
Contours: This is the actual list of contours to draw. The previous contour items update this list each time they are clicked, but the list may be customized prior to clicking the Make Contours button.
Resolution: This determines how detailed (and accurate) the contours will be. At high resolution, contours will be produced based on the value from each pixel of the image. Low resolution will produce contours using the average pixel value in 3x3 sections, resulting in a lot few points to be plotted and, therefore, faster performance. Medium resolution uses 2x2 sections. Using high resolution when the contour intervals are similar in size to the image noise will create an enormous number of points, significantly slowing down POW.
Separate Graph: If this box is checked, when the contours are created, the contours will be placed in a separate graph by itself. Otherwise, the contours will be placed on top of the current graph along with the original image.
Click on the Make Contours button to build and draw the contours. After a set of contours is created, its parameters can still be modified in this dialog box and the contours recreated (replacing the previous version) with the Make Contours button. Contours are created as a POW curve, so one can control its display features (color, line style, etc) from the Edit Graphs dialog box.
If the original image contains WCS information, the contours will be created in terms of celestial coordinates. (Without WCS information, contours will be drawn in pixel coordinates.) As a result, one can place the contours made from one image into a graph containing another image (with its own, possibly different, WCS information) and the contours will be positioned appropriately for the new graph. This can be used to compare observations of the same object at different wavelengths (eg, radio and optical).
fv5.5/tcltk/pow/DefaultOptions.html 0000644 0002207 0000036 00000020304 13224715127 016274 0 ustar birby lheaThe Preferences... item in the Edit menu, brings up a dialog box in which one can set the default display behavior for new graphs. One can control the tick frequency, grid line colors, and scaling for graph axes; color, point styles, and line types for scatter plots; and colormaps and scaling of images. The window has a paned format in which the options affecting each part of the graph has a pane which can be brought forward by clicking the appropriately labeled tab.
This pane sets the application level preferences for how POW looks and behaves. Cursor sets the image to use as the mouse cursor when in POW's main window. POW's "GUI" consists of the 3 pixel readouts, the Scopebox, and the Zoom In/Out buttons usually located at the top of the window. The GUI Position option allows you to move these to any side of the window or turn them off altogether. Scopebox Size alters the size of the scopebox -- the window showing a small overview of the current graph -- or hides it altogether. Resize Window determines whether the POW window will get bigger or smaller (as far as possible) whenever you change the objects in the main POW window, so as to show you everything currently displayed in the main POW window without scrolling. Using the color grid or button, Background Color will set the color to use for the background of all of POW's windows.
This pane has been modified, containing a pair of entry boxes labeled Size, a set of buttons labeled Scaling and new control to choose functionality for right or left mouse buttons [More options are available when editting a real graph (see Edit Graphs).] Enter into the Size boxes, the default width and height to use when creating a new graph. When a graph is created by another program (such as fv), it determines the size of the graph, so these options are usually overridden. The Scaling buttons activate logarithmic graphs. The first row of linear and log buttons cause each axis to be drawn in either linear or logarithmic format. This does not affect the data, just how the graph coordinates are interpretted and labeled. You can control the logarithmic conversion of individual curve data from the Points and Lines panes. The mouse control button can be clicked to switch the functionality of mouse buttons. Default will be left mouse button to control image zoom factor, and right mouse button to control brightness/contrast.
This pane controls the appearance of text in the graph. One can independently set the font, size, style, and color of the Title, Axis Labels, Tick Labels, and default Text Labels. The Text Label value is used only for the initial text label. All subsequent labels inherit their values from the previous label.
This pane controls the appearance of the tick marks and associated grid lines. Use the slidebars to indicate approximately how many tick marks should be drawn (and labeled) on each axis of the graph. At the far left, no tickmarks will be drawn on each axis. At the far right, about 30 may be drawn. The X Ticks and Y Ticks options control whether the X and Y tickmarks are drawn inside or outside the graph's box and whether they are labeled on the left and bottom axes. The Tick Labels option selects between Decimal and Base 60 (degrees minutes seconds) numerical formats. Base 60 is only used when a graph contains WCS information. If the Grid Lines checkbox is selected, lines will drawn on the graph, tracing the path of each tick mark coordinate. One can control the Color and line Style (solid, dashed, etc) of these lines.
The checkbox at the top of this item indicates whether the individual points of the curve should be drawn. The points can be drawn as any of the 7 listed shapes. The size of the points (except Dot which is always 1 point) can either be fixed at a constant size indicated by the slidebar, or drawn with widths/heights indicating the X and Y error bars. If there are X/Y error bars but the points are drawn in a fixed style, the error bars will be indicated by horizontal/vertical lines centered on the point. Points can be Filled or just drawn in outline. Finally, select the desired color from the displayed colorbar. This can be a different color than selected in the Lines pane. At the bottom are a pair of LogX/logY checkbuttons labeled Transform (This is the same option as in the Lines pane). Checking these will cause curves to have the logarithm of their data plotted instead of the data itself. This does not automatically result in logarithmic axes, which are turned on from the Graph pane. Unless you will always want your data to be converted to a certain logarithm format, these options should be left unset.
The checkbox at the top of this pane indicates whether data points will be connected with a continuous line. The line can be of several patterned styles or widths. The points can also be connected directly (Normal) or in a stair-step pattern (Histogram). In the latter mode, the Fill Boxes option draws the histogram as a series of solid boxes instead of an outline. Finally, select the desired color from the displayed colorbar. This can be a different color than selected in the Points pane. At the bottom are a pair of LogX/logY checkbuttons labeled Transform (This is the same option as in the Points pane). Checking these will cause curves to have the logarithm of their data plotted instead of the data itself. This does not automatically result in logarithmic axes, which are turned on from the Graph pane. Unless you will always want your data to be converted to a certain logarithm format, these options should be left unset.
This pane controls the appearance of images. Most of the pane consists of a bunch of different colormaps. They are grouped in the same sequence as listed in the Color menu: smooth, continuous colormaps, followed by ramps, then the step functions. The Invert option will reverse the order of the colormap when turned on. The Scaling option controls how the colormap is applied to the image. For Linear scaling, each colormap level corresponds to a constant intensity range in the image. Square-Root scaling changes the mapping such that the intensity range covered by each color level increases as the square-root function, producing higher contrast at lower intesities. Logarithmic scaling uses the logarithmic function for colormapping, giving even more contrast at low intensities than sqrt. Histo Equalize scaling computes a histogram of the image and tries to distribute colors equally over the number of pixels.
Clicking the Reset button will revert the options to their values when the dialog box was initially opened, undoing any modifications. Clicking the Save button will make the current settings the defaults for new graphs and save them in your .powrc file. The Get Current button grabs any available options from the current graph. Its current image (if present) will be used for the default image options and its first curve (if present) for the default curve options. Exitting will also make the new settings the current defaults, but won't save them.
fv5.5/tcltk/pow/Edit.html 0000644 0002207 0000036 00000005534 13224715127 014231 0 ustar birby lheaA POW Graph consists of a number of Curves and Images drawn within a given rectangular region. The Edit Graph item in the Edit menu brings about a dialog box from which one can control what objects are drawn, how they are displayed, and how the graph itself is drawn...
The dialog box consists of 3 major regions. The top portion controls the contents of the current (or new) graph. The box on the left lists the objects currently in the graph. The box on the right lists all the available objects which are not in the graph. In both boxes, the type of each object (image or curve) will be indicated in parentheses after the objects' names. The Add and Remove buttons in between allows one to move the selected objects between the two lists. The name of the graph being editted is given below the left box. This can be changed if one wants to create a new graph rather than modify the current one. The Edit Objects button under the right box opens up another dialog box which allows one to edit the data structures which define Curves and Images.
The second region, below the graph contents section, contains the editable display options for the graph and graph objects. It has a paned format. At its top are a series of labeled tabs. Click on one of the tabs to view and edit that set of options. Each tab and its options are described below...
This pane contains the highest-level options affecting a graph's appearance. The first entry box contains the graph's title string. By default it is the graph name used internally by POW, but it can be any string or even blank. The entry boxes list, for both the X and Y axes, the Label to be written, the Min and Max values of the axis (actually, the lower-left and upper-right bounds of the graph's display region), the Units label of the values (printed within parentheses after the axis label), and the Size of the graph on the screen in pixels. Any or all of these may be NULL which tells POW to use the default values. In the case of the bounding box (Min/Max), default values will be determined by the minimum values required to display all the graph's contents. For Units, a NULL value will indicate not to list any units in the label axes. Clicking the Reset Min/Max button at the bottome sets all the bounding box values to NULL.
Below the entry boxes are a set of buttons labeled Scaling. These activate logarithmic graphs. The first row of linear and log buttons cause each axis to be drawn in either linear or logarithmic format. This does not affect the data, just how the graph coordinates are interpretted and labeled. The Scale curve data to axes check button determines whether the curves in this graph will be converted to the same axis format. Do not check this if any of your curves already contain logarithmic values (instead of the true values) and you only need to change how the axes are displayed, not how the curves are plotted. You can control the logarithmic conversion of individual curve data from the Points and Lines panes.
This pane controls the appearance of text in the graph. One can independently set the font, size, style, and color of the Title, Axis Labels, Tick Labels, and default Text Labels. The Text Label value is used only for the initial text label. All subsequent labels inherit their values from the previous label.
This pane controls the appearance of the tick marks and associated grid lines. Use the slidebars to indicate approximately how many tick marks should be drawn (and labeled) on each axis of the graph. At the far left, no tickmarks will be drawn on each axis. At the far right, about 30 may be drawn. The X Ticks and Y Ticks options control whether the X and Y tickmarks are drawn inside or outside the graph's box and whether they are labeled on the left and bottom axes. The Tick Labels option selects between Decimal and Base 60 (degrees minutes seconds) numerical formats. Base 60 is only used when a graph contains WCS information. If the Grid Lines checkbox is selected, lines will drawn on the graph, tracing the path of each tick mark coordinate. One can control the Color and line Style (solid, dashed, etc) of these lines.
The checkbox at the top of this item indicates whether the individual points of the curve should be drawn. The points can be drawn as any of the 7 listed shapes. The size of the points (except Dot which is always 1 point) can either be fixed at a constant size indicated by the slidebar, or drawn with widths/heights indicating the X and Y error bars. If there are X/Y error bars but the points are drawn in a fixed style, the error bars will be indicated by horizontal/vertical lines centered on the point. Points can be Filled or just drawn in outline. Finally, select the desired color from the displayed colorbar. This can be a different color than selected in the Lines pane.
At the bottom of the pane is a pair of LogX/logY checkbuttons. Checking these will cause this curve to have the logarithm of its data plotted instead of its true values. If the data is logarithmic already, leave these options unchecked, but select the appropriate Scaling mode in the Graph options (see above).
The checkbox at the top of this pane indicates whether data points will be connected with a continuous line. The line can be of several patterned styles or widths. The points can also be connected directly (Normal) or in a stair-step pattern (Histogram). In the latter mode, the Fill Boxes option draws the histogram as a series of solid boxes instead of an outline. Finally, select the desired color from the displayed colorbar. This can be a different color than selected in the Points pane.
At the bottom of the pane is a pair of LogX/logY checkbuttons. Checking these will cause this curve to have the logarithm of its data plotted instead of its true values. If the data is logarithmic already, leave these options unchecked, but select the appropriate Scaling mode in the Graph options (see above).
This pane controls the appearance of images. Most of the pane consists of a bunch of different colormaps. They are grouped in the same sequence as listed in the Color menu: smooth, continuous colormaps, followed by ramps, then the step functions. The Invert option will reverse the order of the colormap when turned on. The Scaling option controls how the colormap is applied to the image. For Linear scaling, each colormap level corresponds to a constant intensity range in the image. Square-Root scaling changes the mapping such that the intensity range covered by each color level increases as the square-root function, producing higher contrast at lower intesities. Logarithmic scaling uses the logarithmic function for colormapping, giving even more contrast at low intensities than sqrt. Histo Equalize scaling computes a histogram of the image and tries to distribute colors equally over the number of pixels. The Range entry boxes at the bottom list the intensity range over which the colormap should be applied. Initially, they will contain the full intensity range of the image. The Reset button resets these values to the full range of the image.
At the very bottom of the dialog box are 3 buttons. Apply will update the selected graph using the modified parameter values. The Reset button will reset the parameter options and object lists based on the currently selected graph (for when one either wants to revert to the original parameters, or if one selected a new graph, or if new objects were created). The Exit button closes the dialog box. Any changes will be lost if not Applyed before exitting.
fv5.5/tcltk/pow/EditObjects.html 0000644 0002207 0000036 00000007642 13224715127 015545 0 ustar birby lheaThe Edit Objects dialog box has much the same layout as the Edit Graphs dialog box. It is divided into 3 regions...
At the top of the dialog box are two list boxes. The box on the left lists all known display objects (curves and images). The box on the right lists all known data objects. The number following the data objects' names indicates the number of values contained within each object. (The NULL data object is used to specify no data for certain elements of Curve objects.) The name of the display object being editted is indicated by the entry box below the left box. New objects are editted by simply entering a unique name. (Note that curves and images are treated separately, so one can have both a curve and image with the same name.) The Edit Data button on the right currently does nothing. In a future release, one will be able to edit old and create new data objects.
The middle portion of the dialog box lists the parameters defining the selected object. Using the pair of radio buttons at the top of this region one can alternate (or convert) between editting the object as a Curve or Image...
A POW Curve is formed by specifying up to 4 data objects: X, Y, X-error, and Y-error. To assign data to the curve, highlight one of the data objects in the top right box and then click on the appropriate button in the curve parameter list. Either X or Y must be specified, but the others are all optional. If an X or Y data object is given as "NULL", POW will generate a simple integer count instead.
A curve can contain WCS information which allows it to be plotted in celestial coordinates instead of pixels. Enter (or edit) the values at the bottom of the parameter list and select the WCS Info check box.
A POW Image is created from a single data object; highlight the desired data object and click on the Data button. The NULL data object cannot be used for an image. The Units entry box lists the units of the array values (not the X/Y coordinates). A data object is one-dimensional, so the image needs to know how to convert the data into a 2-D array. This is done by entering the X and Y Dimensions of the image in the first pair of entry boxes. Below them are the 3 image scale parameters. Origin specifies the coordinates of the center of the bottom left pixel of the image. By convention, FITS images have an origin of (1,1) when specified in pixels. The Pixel Size specifies the linear scale of the pixels (in units/pixel) and Units specify the physical units used for the Orign and Pixel Size.
An image can contain WCS information which allows it to be labeled in celestial coordinates instead of pixels. Enter (or edit) the values at the bottom of the parameter list and select the WCS Info check box. WCS information overrides the image scale parameters (origin, pixel size, and units).
At the bottom of the dialog box are 3 buttons. Create Object creates the indicated object. If the Object Name is unique, a new object will be created otherwise, it will replace the old version. (Note than a curve and image can have the same name and but will still be considered unique.) Creating/Editting an object does not immediately affect the graphs in which that object already exists, so it is necessary to update them manual from the Edit Graphs dialog box. Reload Info will reset the parameter list and update the object/data boxes with the current list of known objects. The Exit button closes the dialog box. Any changes will be lost if an object wasn't created before exitting.
fv5.5/tcltk/pow/File.html 0000644 0002207 0000036 00000000753 13224715127 014221 0 ustar birby lheaUsers can add short text strings to a graph in a number of fonts, sizes, and styles. To add a label, select the graph to be used, then choose the Add Text Labels command in the Edit menu. The Annotations window will come up.
Type in the string to be created in the top entry box and select the appropriate display options. Only a small subset of commonly-used font families are included in the font listing. Click the color button to specify a color. (Note: For the first label created, the default font values found here are obtained from the Edit Graph/Set Default Options settings for Text Labels. For all subsequent labels, though, the values are inheritted from the previous label created.)
The Position entry boxes list the coordinates at which the label is to be placed; the position corresponds to the bottom left corner of the text string. The values are interpretted based on the following option.
The Attach To radiobuttons determine how the Position values are interpretted and how the text handled. The Graph option will make the label a graph object which will be placed at a fixed position relative to the graph but independent of the axes values (like the title or axis labels). The lower-left corner of the graph is position 0,0 and the top-right corner is 1,1. The label can be placed outside the graph as well as inside. Zooming has no effect on it, but resizing the graph will move the label so that its relative position is the same. This option is good for adding notes or legends to the graph. The Coordinates option will make the label a plotted object which will be placed according to the graph's axes. If the indicated position is not within the current bounds -- due to zooming or panning -- the label will not be displayed. This option is good for labeling objects in images or parts of curves. The Position values will be converted between these two coordinate systems when the option is changed.
The Add button creates a new label. The Delete button removes the current label from the graph. And the Apply button modifies the current label.
Once created, labels can be repositioned by dragging them with the left mouse button. If a label is attached to a graph's Coordinates and you drag it outside the graph, the label will disappear when dropped. The label still exists, but is just positioned outside the graph's axes range. Alter the axes to display the labels new position.
Double-clicking a label will bring up the Annotations window, if it doesn't already exist, with the label's information. When this window is open, a single-click is sufficient for selecting a different label for editting.
fv5.5/tcltk/pow/Makefile 0000644 0002207 0000036 00000006337 13224715127 014120 0 ustar birby lhea HD_COMPONENT_NAME = tcltk HD_COMPONENT_VERS = HD_LIBRARY_ROOT = pow HD_LIBRARY_SRC_c = PowCanvCurve.c PowColormap.c PowCommands.c \ PowCreateCurve.c PowCreateData.c PowCreateGraph.c \ PowCreateImage.c PowCreateVector.c \ PowEventHandlers.c PowGrid.c PowInit.c PowUtils.c \ PowWCS.c Visu_colors.c Visu_generic.c Visu_Init.c \ Visu_lut.c Visu_shared_colors.c Visu_tkImgPict.c # unused: orbit.c PowDrvr.c readpha.c tclShared.c tkAppInit.c HD_CFLAGS = -I${TCL_DIR}/../generic -I${TK_DIR}/../generic \ ${XINCLUDES} ${HD_STD_CFLAGS} \ -DVISU_LIBRARY=\"${HD_LIB}/pow\" HD_INSTALL_LIBRARIES = ${HD_LIBRARY_ROOT} HD_SHLIB_LIBS = ${HD_LFLAGS} -l${CFITSIO} -l${TCL} -l${TK} ${XLIBS} ${CURL_LIB} HD_ADD_SHLIB_LIBS = yes HD_INSTALL_SHELL_SCRIPTS = POWplot HD_INSTALL_HEADERS = pow.h tkpict.h HD_INSTALL_EXTRA = install-pow-extras default: build-libpow all: default publish include ${HD_STD_MAKEFILE} # Get cfitsio source files and prepend ${CFITSIO_DIR} prefix to each filename. CFITSIO_OBJ_TMP = ${shell if [ -f ${CFITSIO_DIR}/Makefile ]; then ${MAKE} -f ${CFITSIO_DIR}/Makefile cfitsioLibObjs; fi | grep buffers} CFITSIO_OBJ = ${shell if [ "x${CFITSIO_OBJ_TMP}" != "x" ]; then echo ${CFITSIO_OBJ_TMP}; fi | sed "s: : ${CFITSIO_DIR}/:g" | sed "s:^:${CFITSIO_DIR}/:"} ${CFITSIO_OBJ}: @for file in ${CFITSIO_OBJ}; do \ if [ ! -f $$file ]; then \ echo "Cannot find CFITSIO object $$file"; exit 1; \ fi; \ done # Get wcslib source files and prepend ${WCSLIB_DIR} prefix to each filename. WCSLIB_OBJ_TMP = ${shell if [ -f ${WCSLIB_DIR}/makedefs ]; then cd ${WCSLIB_DIR}/C; ${MAKE} echo_modules FLAVOUR=${WCSFLAV} WCSTRIG=WRAPPER; fi | grep fitshdr} WCSLIB_OBJ = ${shell if [ "x${WCSLIB_OBJ_TMP}" != "x" ]; then echo ${WCSLIB_OBJ_TMP}; fi | sed "s: : ${WCSLIB_DIR}/C/:g" | sed "s:^:${WCSLIB_DIR}/C/:"} ${WCSLIB_OBJ}: @for file in ${WCSLIB_OBJ}; do \ if [ ! -f $$file ]; then \ echo "Cannot find WCSLIB object $$file"; exit 1; \ fi; \ done wcslib-obj-remove: rm -f ${WCSLIB_OBJ} ${WCSLIB_DIR}/C/libwcs-PIC.a build-libpow: @if [ "x${CFITSIO_OBJ}" = x ]; then \ echo "CFITSIO_OBJ macro is empty"; exit 1; \ fi @if [ "x${WCSLIB_OBJ}" = x ]; then \ echo "WCSLIB_OBJ macro is empty"; exit 1; \ fi ${HD_MAKE} pow HD_LIBRARY_ROOT=pow \ HD_LIBRARY_OBJ="${HD_LIBRARY_SRC_c:.c=.${OSUF}} ${CFITSIO_OBJ} ${WCSLIB_OBJ}" POW_TCL = html_library.tcl notebook.tcl Notifications.tcl \ PowCmdsClass.tcl powEdit.tcl powImgProbe.tcl \ powMovie.tcl POWplot.tcl powProfile.tcl powRgn.tcl \ powRuler.tcl powScript.tcl pow.tcl RegionList.tcl \ Region.tcl Shape.tcl visu_widgets.tcl tclIndex \ powXRange.tcl POW_HTML = About.html Blinking.html Color.html Contours.html \ DefaultOptions.html EditGraphs.html Edit.html \ EditObjects.html File.html Labels.html \ Moving_Graphs.html Options.html Overview.html \ POWAPI.html Probe.html Profile.html Regions.html \ ROI.html Ruler.html Scripting.html Tools.html \ PrintControl.html XRange.html POW_EXTRAS = mhh7.gif stretcharrow.xbm # pow.def pow.dsp pow.dsw powMacResource.r pow.pch pow.sit.hqx install-pow-extras: @for extra in ${POW_TCL} ${POW_HTML} ${POW_EXTRAS}; do \ ${HD_INSTALL} $$extra ${HD_LIB}/pow/$$extra ${HD_CP_P}; \ done fv5.5/tcltk/pow/Makefile.develop 0000644 0002207 0000036 00000001602 13224715127 015543 0 ustar birby lhea CFLAGS = -g -I../local/include/itcl -I../visu-2.0/src -I../fitsTcl/cfitsio LDFLAGS = -g -L. -lpow -L../fitsTcl/ -lcfitsio -L../visu-2.0/src -lVISU2.0 -L../local/lib/itcl/ -ltk4.1i -ltcl7.5i -lX11 -lm SRC = PowCommands.o \ PowCreateCurve.o PowCreateData.o \ PowCreateGraph.o PowCreateImage.o \ PowCreateVector.o PowEventHandlers.o \ PowInit.o PowUtils.o \ readpha.o all: libpow.a libpow.so $(CC) $(CFLAGS) tkAppInit.c -o powwish $(LDFLAGS) libpow.a: $(SRC) rm -f libpow.a ar r libpow.a $(SRC) libpow.so : $(SRC) rm -f libpow.so ld -shared -o libpow.so $(SRC) install: libpow.a libpow.so cp libpow.a ../local/include cp libpow.so ../local/lib cp pow.tcl ../local/lib clean: rm -rf *.o *~ powwish *.a *.so .f.a: $(FC) $(FFLAGS) -c $*.f $(AR) $(ARFLAGS) $@ $(