C
C *** OUTPUT OF SPECTRUM DATA ON SCREEN AND FILE DATA ***
C
      SUBROUTINE SPCOUT(FOM,DOM,NOM,MOM,SPC)
C
C ** FOM    : FIRST CIRCULAR FREQUENCY ( OMEGA )
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 ** SPC(I) : SPECTRUM ( COMPLEX*8 )
C
      COMPLEX*8 SPC(32800)
C
C *** MOM CHECK ***
C
      IF(MOM.NE.32800)THEN
      WRITE(*,*)' FROM SUBROUTINE SPCOUT :'
      WRITE(*,*)' MOM.NE.32800 !!!!, THEN STOP !!!!'
      STOP
      END IF
C
C *** SPECTRUM OUTPUT ON SCREEN ***
C 
      WRITE(*,1000)
      WRITE(*,1010)
      READ(*,*)NYES
      IF(NYES.NE.0)GOTO 10
C
      WRITE(*,1020)
      IFOM=1
      IF(FOM.EQ.0.0)THEN
      IFOM=2
      WRITE(*,1030)1,FOM,0.0,SPC(1),CABS(SPC(1))
      END IF
C
      DO 100 IOM=IFOM,NOM
      OM=FLOAT(IOM-1)*DOM+FOM
      PER=6.2831853070/OM
      WRITE(*,1030)IOM,OM,PER,SPC(IOM),CABS(SPC(IOM))
  100 CONTINUE
C
      WRITE(*,*)
 1000 FORMAT(/' FROM SUBROUTINE SPCOUT : SPECTRUM OUTPUT')
 1010 FORMAT(' SPECTRUM DATA OUTPUT ON SCREEN ? ( YES = 0 ) : ',\)
 1020 FORMAT(/' NUM., OMEGA, PERIOD,  SPC(REAL),  SPC(IMAG),  SPC(ABS)')
 1030 FORMAT(I4,2F8.3,3E12.4)  
C
C *** FILE OUTPUT TO FILE DATA ***
C
   10 WRITE(*,2000)
 2000 FORMAT(' FILE OUTPUT ? ( YES = 0 : SPC.DAT ) ',\)
      READ(*,*)NYES
      IF(NYES.NE.0)GOTO 20
C
      OPEN(7,FILE='SPC.DAT')
      DO 200 IOM=1,NOM,8
      WRITE(7,2100)(CABS(SPC((IOM-1)+I)),I=1,8)
  200 CONTINUE
      CLOSE(7)
 2100 FORMAT(8F10.4)
   20 WRITE(*,*)
C
      RETURN
      END
