C
C=======================================================================
C
      SUBROUTINE STOP_EXT(I_EXT,I_EXT_A,SPECTRO)
C
C  This routine stops the code when the dimension N_TILT_M in the
C      spec.inc file is insufficient for the number of values to
C      Gaussian average over (as generated by the ext_dir.f code)
C
      USE DIM_MOD
C
      USE INFILES_MOD
      USE INUNITS_MOD
      USE OUTUNITS_MOD
C
C
C
      CHARACTER*3 SPECTRO
C
      NSET=1
      NSET_A=1
C
      IF((SPECTRO.EQ.'PHD').OR.(SPECTRO.EQ.'AED')) THEN
        IF(I_EXT.EQ.-1) THEN
          OPEN(UNIT=IUI6, FILE=INFILE6, STATUS='OLD')
          READ(IUI6,15) IDIR,NSET
          CLOSE(IUI6)
        ENDIF
        IF(I_EXT_A.EQ.-1) THEN
          OPEN(UNIT=IUI6, FILE=INFILE6, STATUS='OLD')
          READ(IUI6,15) IDIR,NSET_A
          CLOSE(IUI6)
        ENDIF
      ENDIF
      IF(SPECTRO.EQ.'APC') THEN
        IF(I_EXT.EQ.-1) THEN
          OPEN(UNIT=IUI6, FILE=INFILE6, STATUS='OLD')
          READ(IUI6,15) IDIR,NSET
          CLOSE(IUI6)
        ENDIF
        IF(I_EXT_A.EQ.-1) THEN
          OPEN(UNIT=IUI9, FILE=INFILE9, STATUS='OLD')
          READ(IUI9,15) IDIR,NSET_A
          CLOSE(IUI9)
        ENDIF
      ENDIF
C
      IF(MAX(NSET,NSET_A).GT.N_TILT_M) THEN
        WRITE(IUO1,10) MAX(NSET,NSET_A)
        STOP
      ENDIF
C
  10  FORMAT(///,16X,'<<<<<<<<<<  N_TILT_M SHOULD BE AT LEAST ',I3,'  >>
     &>>>>>>>>')
  15  FORMAT(6X,I1,1X,I3)
C
      RETURN
C
      END
