      SUBROUTINE COORD(TYP)
C
C SUBROUTINE TO CONVERT BETWEEN THE 5 POSSIBLE COORDINATE SYSTEMS USED
C INPLOTTING WRIITEN BY RAY GOEHNER 12/83
C
C US USER TO SCREEN X&Y
C SU SCREEN TO USER X&Y
C MS MATRIX TO SCREEN X ONLY
C SM SCREEN TO MATRIX  X ONLY
C UM USER TO MATRIX CALCULATED IE NS & NF
C MU MATRIX TO USER
C
C DSP=0 LINEAR DISPLAY
C DSP=1 INTEGRAL DISPLAY
C DSP=2 SEMI-LOG DISPLAY
C DSP=3 SQRT DISPLAY
C
      COMMON /CRD/AUSX,BUSX,AUSY,BUSY,ASUX,BSUX,ASUY,BSUY,AMSX,BMSX
     1,ASMX,BSMX,AUMX,BUMX,AMUX,BMUX,DSP,ITERM,N,NS,NF
      COMMON /SCN/ XS,XF,YS,YF,XXS,XXF,YYS,YYF,CSTR,CFIN,CYMIN,CYMAX,STR
     1,FIN,YMIN,YMAX,ZZ,CW,CH,ISP,JSP,IFL
C
      BYTE DSP,ITERM,TYP
C
C CALCULATE NS STARTING PT IN MATRIX & NF ENDING PT IN INTENSITY MATRIX
C
      AUMX=FLOAT(N-1)/(FIN-STR)
      BUMX=FLOAT(N)-AUMX*FIN
      NS=AUMX*CSTR+BUMX+0.49
      NF=AUMX*CFIN+BUMX+0.49
      AMUX=1./AUMX
      BMUX=FIN-AMUX*FLOAT(N)
      CSTR=AMUX*FLOAT(NS)+BMUX
      IF(NF.LE.N) CFIN=AMUX*FLOAT(NF)+BMUX
C
C DO X CONVERSIONS THEN Y     
C
      ASUX=(CFIN-CSTR)/(XXF-XXS)
      BSUX=CFIN-ASUX*XXF
      AUSX=(XXF-XXS)/(CFIN-CSTR)
      BUSX=XXF-AUSX*CFIN
C
      IF(TYP.EQ.1.OR.TYP.EQ.3.OR.TYP.EQ.5) GO TO 100
      AMUX=(CFIN-CSTR)/FLOAT(NF-NS)
      BMUX=CFIN-AMUX*FLOAT(NF)
      AUMX=1./AMUX
      BUMX=FLOAT(NF)-AUMX*CFIN
C
      AMSX=(XXF-XXS)/FLOAT(NF-NS)
      BMSX=XXF-AMSX*FLOAT(NF)
      ASMX=1.0/AMSX
      BSMX=FLOAT(NF)-ASMX*XXF
C
  100 ASUY=(CYMAX-CYMIN)/(YYF-YYS)
      BSUY=CYMAX-ASUY*YYF
      AUSY=1./ASUY
      BUSY=YYF-AUSY*CYMAX
C
      RETURN
      END
