	program eicplot
C
C	PLOTS EIC CONTOURS.
C	ON 28 MAR 1997, I RAN A SERIES OF SIX OSCARS RUNS, AND I COPIES
C	THE OUTPUTS, FOR008. TO FOR009. FOR SAFETY.  THIS PROGRAM READ
C	THEM IN AND MAKES A MATRIX FOR CONTOUR PLOTS, THEN MAKES THE
C	CONTOUR AND 3D PLOTS
C
C	THE OSCARD.DAT INPUT CARDS FOR THE FIRST RUN, LOWEST KZ, WERE:
C
C .000011519-.00000033   .021    .010       .00050  1.01  1.05 1.00 249 1
C -1.   E+001.    E+000.    E+00.846  E-04.846  E-04
C 1.836 E+031.    E+000.    E-03.6915 E-07.34575E-07
C
C ABOVE IS FOR SOLAR WIND .3 AU, TE = 43 EV, T PROTON=43 EV, EIC 
C
	COMMON /PLOTSTUFF/ XKXMAX,XKXMIN,XKZMAX,XKZMIN,TRATIO,WCE
     1		,RATIOM
	CHARACTER*12 INFILE
	CHARACTER*80 JUNK
	REAL RP(49,6),IP(49,6)
	DATA XKXMAX,XKXMIN,XKZMAX,XKZMIN /-10000.,1000.,-10000,1000./
C
	DO NINP = 1,6
	  NKX = 0
	  WRITE(INFILE,1001) NINP
 1001	  FORMAT('FOR009.DAT;',I1)
	  PRINT*,INFILE
	  OPEN(UNIT=44,FILE=INFILE,TYPE='OLD',READONLY)
 	  READ(44,1003,END=102) WR,WI,WCE,XKX,XKZ,RW,RKX,RKZ,NC,NIT,MODE
 1003	  format (1x,e11.5,e12.5,6E12.5,1X,3I2)
	  DO I = 1,NC
	    READ(44,1004) RATIOM,DENS,BETA,TPAR,TPERP
 1004	    FORMAT(5E10.4)
	  ENDDO
		PRINT*,RATIOM,DENS,BETA,TPAR,TPERP
	  TRATIO = TPAR/TPERP
		PRINT*,'TRATIO=',TRATIO
 101	  READ(44,1002,END=102) WR,WI,DET,DETR,DETI,XKX,XKZ
 1002	  format (1x,e12.6,1x,e10.3,1x,2f8.3,1x,f6.3,e12.4,1x,e11.4)
	  NKX = NKX+1
	  XKXMAX = AMAX1(XKX,XKXMAX)
	  XKZMAX = AMAX1(XKZ,XKZMAX)
	  XKXMIN = AMIN1(XKX,XKXMIN)
	  XKZMIN = AMIN1(XKZ,XKZMIN)
	  RP(NKX,NINP) = WR
	  IP(NKX,NINP) = -WI
	  GO TO 101
 102	  CONTINUE	  
	ENDDO
C
C	NOW MAKE THE PLOT, OR PLOTS
	NKX = 49
	NKZ = 6
	ITERM = -1
	CALL MYCONTOUR(RP,IP,NKX,NKZ,ITERM)
C
	STOP
	END
	SUBROUTINE MYCONTOUR(RP,IP,NKX,NKZ,ITERM)
C
	COMMON /MONGOPAR/
     1  X1,X2,Y1,Y2,GX1,GX2,GY1,GY2,LX1,LX2,LY1,LY2,
     1  GX,GY,CX,CY,
     1  EXPAND,ANGLE,LTYPE,LWEIGHT,
     1  CHEIGHT,CWIDTH,CXDEF,CYDEF,PXDEF,PYDEFF,COFFMGO,
     1  TERMOUT,XYSWAPPED,NUMDEV,
     1  PIMGO,USERVAR(10),AUTODOT
C
	COMMON /PLOTSTUFF/ XKXMAX,XKXMIN,XKZMAX,XKZMIN,TRATIO,WCE
     1		,RATIOM

C
	CHARACTER*60 LABEL
	REAL RP(49,6),IP(49,6),IPMIN,IPMAX,IPMAXT
	REAL ZLEVELS(20)
C
        CALL MGOINIT
        CALL MGOSETUP(ITERM)                       !TERMINAL
        CALL MGOERASE
C
	RPMAX = -1000.
	RPMIN = 1000.
	DO NX = 1,49
	  DO NZ = 1,6
		IF(RP(NX,NZ).GT.RPMAX) THEN
		  RPMAX = RP(NX,NZ)
		  MAXX = NX
		  MAXZ = NZ
		ENDIF
		IF(RP(NX,NZ).LT.RPMIN) THEN
		  RPMIN = RP(NX,NZ)
		  MINX = NX
		  MINZ = NZ
		ENDIF
	  ENDDO
	ENDDO
C
	TINC = .03*(GY2-GY1)
	YLINE = GY2-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOSETEXPAND(.7)
	WRITE(LABEL,1003) WCE/RATIOM
 1003	FORMAT(' ION CYCLO FREQ ',E12.4)
	CALL MGOLABEL(28,LABEL)
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	WRITE(LABEL,1001) RPMAX,RPMIN
 1001	FORMAT(' MAX AND MIN FREQS',E12.4,E12.4)
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOSETEXPAND(.7)
	CALL MGOLABEL(42,LABEL)
	WRITE(LABEL,1002) TRATIO
 1002	FORMAT(' ION TPAR/TPERP',F7.3)
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(23,LABEL)
	CALL MGOSETEXPAND(1.)
C
	IF(ITERM.EQ.-1) THEN
	  CALL MGOSETLOC(GX1,GY1,GX2,2000.)
	ELSEIF(ITERM.EQ.-2) THEN
	  CALL MGOSETLOC(GX1,GY1,GX2,GY2)
	ELSE
	  CALL MGOSETLOC(GX1,GY1,GX2,GY2)
	ENDIF
C
	RPMAXT = RPMAX - .001*(RPMAX-RPMIN)
	RPMIN = RPMIN + .001*(RPMAX-RPMIN)
	RPMAX = RPMAXT 
	DO NZ = 1,11
	  ZLEVELS(NZ) = RPMIN + (NZ-1)*(RPMAX-RPMIN)/10.
	ENDDO
	YLINE = YLINE-TINC
	YLINE = YLINE-TINC
	CALL MGOSETEXPAND(.7)
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(23,'FREQUENCIES OF CONTOURS')
	WRITE(LABEL,1004) (ZLEVELS(I),I=1,5) 
 1004	FORMAT(5E12.4)
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(61,LABEL)
	WRITE(LABEL,1004) (ZLEVELS(I),I=6,10) 
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(61,LABEL)
	WRITE(LABEL,1004) ZLEVELS(11) 
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(61,LABEL)
	CALL MGOSETEXPAND(1.)
C
	CALL MGOCONTOUR(RP,49,6,ZLEVELS,11)
	print*,'limits',xkxmin,xkxmax,xkzmin,xkzmax
	print*,'max (int) x,z',maxx,maxz
	print*,'min (int) x,z',minx,minz
	CALL MGOTICKSIZE(-1.,-1.,-1.,-1.)
	XLOG1 = ALOG10(XKXMIN)
	XLOG2 = ALOG10(XKXMAX)
	ZLOG1 = ALOG10(XKZMIN)
	ZLOG2 = ALOG10(XKZMAX)
C	CALL MGOSETLIM(XKXMIN,XKZMIN,XKXMAX,XKZMAX)
	CALL MGOSETLIM(XLOG1,ZLOG1,XLOG2,ZLOG2)
	CALL MGOBOX(1,2)
C	CALL MGORELOCATE
	CALL MGOXLABEL(9,'Kx c /wpe')
	CALL MGOYLABEL(9,'Kz c /wpe')
	CALL MGOPLOTID('REAL PART',' ')
	IF(ITERM.LT.0) THEN
	  CALL MGOPRNTPLOT(NVEC)
	ENDIF
C
C	NOW DO IMAGINARY PART
C
        CALL MGOINIT
        CALL MGOSETUP(ITERM)                       !TERMINAL
        CALL MGOERASE
C
	IPMAX = -1000.
	IPMIN = 1000.
	DO NX = 1,49
	  DO NZ = 1,6
		IF(IP(NX,NZ).GT.IPMAX) THEN
		  IPMAX = IP(NX,NZ)
		  MAXX = NX
		  MAXZ = NZ
		ENDIF
		IF(IP(NX,NZ).LT.IPMIN) THEN
		  IPMIN = IP(NX,NZ)
		  MINX = NX
		  MINZ = NZ
		ENDIF
	  ENDDO
	ENDDO
C
	TINC = .03*(GY2-GY1)
	YLINE = GY2-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOSETEXPAND(.7)
	WRITE(LABEL,1003) WCE/RATIOM
	CALL MGOLABEL(28,LABEL)
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	WRITE(LABEL,1001) IPMAX,IPMIN
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOSETEXPAND(.7)
	CALL MGOLABEL(42,LABEL)
	WRITE(LABEL,1002) TRATIO
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(23,LABEL)
	CALL MGOSETEXPAND(1.)
C
	IF(ITERM.EQ.-1) THEN
	  CALL MGOSETLOC(GX1,GY1,GX2,2000.)
	ELSEIF(ITERM.EQ.-2) THEN
	  CALL MGOSETLOC(GX1,GY1,GX2,GY2)
	ELSE
	  CALL MGOSETLOC(GX1,GY1,GX2,GY2)
	ENDIF
C
	IPMAXT = IPMAX - .001*(IPMAX-IPMIN)
	IPMIN = IPMIN + .001*(IPMAX-IPMIN)
	IPMAX = IPMAXT 
	DO NZ = 1,11
	  ZLEVELS(NZ) = IPMIN + (NZ-1)*(IPMAX-IPMIN)/10.
	ENDDO
	YLINE = YLINE-TINC
	YLINE = YLINE-TINC
	CALL MGOSETEXPAND(.7)
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(23,'FREQUENCIES OF CONTOURS')
	WRITE(LABEL,1004) (ZLEVELS(I),I=1,5) 
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(61,LABEL)
	WRITE(LABEL,1004) (ZLEVELS(I),I=6,10) 
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(61,LABEL)
	WRITE(LABEL,1004) ZLEVELS(11) 
	YLINE = YLINE-TINC
	CALL MGOGRELOCATE(GX1,YLINE)
	CALL MGOLABEL(61,LABEL)
	CALL MGOSETEXPAND(1.)
C
	CALL MGOCONTOUR(IP,49,6,ZLEVELS,11)
	print*,'limits',xkxmin,xkxmax,xkzmin,xkzmax
	print*,'max (int) x,z',maxx,maxz
	print*,'min (int) x,z',minx,minz
	CALL MGOTICKSIZE(-1.,-1.,-1.,-1.)
	XLOG1 = ALOG10(XKXMIN)
	XLOG2 = ALOG10(XKXMAX)
	ZLOG1 = ALOG10(XKZMIN)
	ZLOG2 = ALOG10(XKZMAX)
C	CALL MGOSETLIM(XKXMIN,XKZMIN,XKXMAX,XKZMAX)
	CALL MGOSETLIM(XLOG1,ZLOG1,XLOG2,ZLOG2)
	CALL MGOBOX(1,2)
C	CALL MGORELOCATE
	CALL MGOXLABEL(9,'Kx c /wpe')
	CALL MGOYLABEL(9,'Kz c /wpe')
	CALL MGOPLOTID('IMAGINARY PART',' ')
	IF(ITERM.LT.0) THEN
	  CALL MGOPRNTPLOT(NVEC)
	ENDIF
	RETURN
	END
