C
C *** OUTPUT OF AMPLITUDE SPETRUM TO PLOTTER ***
C
      SUBROUTINE SPAPLT(FOM,DOM,NOM,MOM,SPCA)
C
C ** FOM     : FIRST CIRCULAR FREQUENCY : OMEGA OF SPCA(1)
C ** DOM     : INCREMENT OF CIRCULAR FREQUENCY ( DELTA OMEGA )
C ** NOM     : TOTAL NUMBER OF CIRCULAR FREQUENCY
C ** MOM     : NOM IN MAIN PROGRAM DIMENSION
C            : IF MOM > 2**13(=8192), CAN NOT USE !!!
C ** SPCA(I) : FOURIER SPECTRUM AMPLITUDE
C    ( FOURIER SPECTRUM = FOURIER COEFFICIENTS * DURATION/2.0 )
C
      DIMENSION SPCA(MOM)
      CHARACTER YUNIT*10
C
C *** SEARCH OF MAXIMUM AMPLITUDE AND FINAL OMEGA ***
C
      AMX=0.0
      DO 100 IOM=1,NOM
        APC=SPCA(IOM)
        IF(APC.GE.AMX)THEN
        AMX=APC
        IOMMX=IOM
        END IF
  100 CONTINUE
C
      EOM=FOM+DOM*FLOAT(NOM-1)
      OMMX=FOM+DOM*FLOAT(IOMMX-1)
C
C *** OUTPUT OF DATA INFORMATION ***
C
      WRITE(*,*)
      WRITE(*,1000)
   10 WRITE(*,1010)
      WRITE(*,1020)DOM,NOM
      WRITE(*,1030)FOM,EOM
      WRITE(*,1040)AMX,OMMX
 1000 FORMAT(' FROM SUBROUTINE SCAPLT : AMPLITUDE SPETRUM PLOT')
 1010 FORMAT(/' DATA INFORMATION :')
 1020 FORMAT(' DELTA OMEGA = ',F8.4,' ,OMEGA NUMBER = ',I5)
 1030 FORMAT(' FIRST OMEGA = ',F8.4,' ,FINAL OMEGA = ',F8.4)
 1040 FORMAT(' MAXIMUM AMPLITUDE = ',F10.5,' , OMEGA = ',F8.4/)
C
C *** AXIS DATA INPUT ***
C
      WRITE(*,1200)
 1200 FORMAT(' AXIS OFF ? ( YES = 0 ENTER ) :',\)
      READ(*,*)NAXY
C
      IF(NAXY.EQ.0)THEN
C
        OPEN(5,FILE='AX.DAT')
        READ(5,1210)XOR,YOR,XFAC,YFAC,OLDFOM,XVAL,NST0
        CLOSE(5)
 1210   FORMAT(6E15.7,I5)
        OM1=FOM
        IF(NST0.NE.0)OM1=FOM-OLDFOM
C
      ELSE
C
        WRITE(*,1300)
        WRITE(*,1310)
        READ(*,*)NST0
        OM1=0.0
        OM2=FOM
        IF(NST0.EQ.0)OM1=FOM
        IF(NST0.EQ.0)OM2=0.0
        WRITE(*,1320)
        READ(*,*)XVAL
        WRITE(*,1330)
        READ(*,*)XLEN
        XLEN=XLEN*100.0
        WRITE(*,1340)
        READ(*,*)NUX
        XFAC=XLEN/(XVAL-OM2)
        WRITE(*,1350)
        READ(*,*)YVAL
        WRITE(*,1360)
        READ(*,*)YLEN
        YLEN=YLEN*100.0
        WRITE(*,1370)
        READ(*,*)NUY
        YFAC=YLEN/YVAL
        WRITE(*,1380)
        READ(*,*)IYUT
        IF(IYUT.EQ.1)YUNIT='  (CM*SEC)'
        IF(IYUT.EQ.2)YUNIT='(KINE*SEC)'
        IF(IYUT.EQ.3)YUNIT=' (GAL*SEC)'
        IF(IYUT.EQ.4)YUNIT='          '
 1300   FORMAT(' AXIS DATA INPUT :')
 1310   FORMAT(' X-AXIS START FROM 0.0 OR FIRST OMEGA ?'
     *        /' IF START 0.0 OMEGA, PLEASE ENTER 0 :',\) 
 1320   FORMAT(/' ENTER X-AXIS MAX ( MAX OMEGA ) :',\)
 1330   FORMAT(' ENTER X-AXIS LENGTH ( OMEGA : cm ) :',\)
 1340   FORMAT(' ENTER X-AXIS UNIT NUMBER :',\)
 1350   FORMAT(/' ENTER Y-AXIS MAX VALUE ( Y-AXIS AMP > MAX AMP ) :',\)
 1360   FORMAT(' ENTER Y-AXIS LENGTH ( AMP : cm ) :',\)
 1370   FORMAT(' ENTER Y-AXIS UNIT NUMBER :',\)
 1380   FORMAT(/' 1: DISP(CM*SEC),  2: VEL(KINE*SEC),'/,
     *         ' 3: ACC(GAL*SEC),  4: NON DIMENDION :',\)
C
        WRITE(*,1500)
        READ(*,*)XOR
        XOR=(2.0+XOR)*100.0
        WRITE(*,1510)
        READ(*,*)YOR
        YOR=(2.0+YOR)*100.0
        WRITE(*,1520)
        READ(*,*)IYES
        IF(IYES.NE.0)GOTO 10
 1500   FORMAT(/' ENTER X ORIGIN POSITION (cm):',\)
 1510   FORMAT(' ENTER Y ORIGIN POSITION (cm):',\)
 1520   FORMAT(/' ALL INPUT DATA OK ? ( YES = 0 ) :',\)
C
      END IF
C
C *** OUTPUT PLOTTER DATA ***
C 
      OPEN(6,FILE='PS.DAT')
C
      IF(NAXY.EQ.0)GOTO 20
C
C   * PEN, TERM, AXIS AND CHARACTER *
C
      WRITE(6,2000)
      WRITE(6,2010)
      WRITE(6,2020)XOR,YOR
      WRITE(6,2030)XLEN,NUX
      WRITE(6,2020)XOR-110.0,YOR-60.0
      WRITE(6,2040)OM2
      WRITE(6,2020)XOR+XLEN-100.0,YOR-60.0
      WRITE(6,2040)XVAL
      WRITE(6,2020)XOR+XLEN-220.0,YOR-120.0
      WRITE(6,2050)
      WRITE(6,2020)XOR,YOR
      WRITE(6,2060)YLEN,NUY
      WRITE(6,2020)XOR-40.0,YOR-80.0
      WRITE(6,2070)0.0
      WRITE(6,2020)XOR-40.0,YOR+YLEN-80.0
      WRITE(6,2075)YVAL
      WRITE(6,2020)XOR-100.0,YOR+YLEN-250.0
      WRITE(6,2080)YUNIT
 2000 FORMAT(2HJ1)
 2010 FORMAT(3H=<<)
 2020 FORMAT(1HM,F6.1,1H,F6.1,1H,)
 2030 FORMAT(3HX3,,F6.1,1H,I2,2H<<)
 2040 FORMAT(7HR0,S30,,1HP,F5.1,2H<<)
 2050 FORMAT(7HR0,S30,,12HP(RAD/SEC)<<)
 2060 FORMAT(3HX2,,F6.1,1H,I2,2H<<)
 2070 FORMAT(9HR900,S30,,1HP,F4.1,2H<<)
 2075 FORMAT(9HR900,S30,,1HP,F5.1,2H<<)
 2080 FORMAT(9HR900,S30,,1HP,A10,2H<<)
C
C   * DATA PLOT *
C
   20 WRITE(6,2100)XOR+OM1*XFAC,YOR+SPCA(1)*YFAC
      DO 200 IOM=2,NOM
      OMX=OM1+DOM*FLOAT(IOM-1)
      WRITE(6,2110)XOR+OMX*XFAC,YOR+SPCA(IOM)*YFAC
      IF(OMX.GE.XVAL)GO TO 30
  200 CONTINUE
   30 WRITE(6,2100)XOR+(OM1+DOM*FLOAT(IOM))*XFAC+500.0,YOR
 2100 FORMAT(1HM,F6.1,1H,F6.1,1H,)
 2110 FORMAT(1HD,F6.1,1H,F6.1,1H,)
C
      CLOSE(6)
C
C *** AXIS DATA OUTPUT TO FILE ***
C
      IF(NAXY.NE.0)THEN
        OPEN(5,FILE='AX.DAT')
        WRITE(5,2200)XOR,YOR,XFAC,YFAC,FOM,XVAL,NST0
        CLOSE(5)
 2200   FORMAT(6E15.7,I5)
      END IF
C
      WRITE(*,3000)
 3000 FORMAT(/' USE FOR PLOTTER : A> COPY PS.DAT PRN')
      WRITE(*,*)
C
      RETURN
      END
