      subroutine executioner
      include 'MOP6FILE'
*
*              This  is  a new and drastically improved
*              subroutine capable of killing even such
*              a sturdy creature as MOPAC v. 6.0
*
*              However, it will do its best to look after
*              the user. It is responsible for closing files
*              before killing current task
c
c
c
c     parameter (Nfiles = 12,       ! <=== put here the number of files
c                                   !      that your customer dreamed
c                                   !      to use
c                                   !      (12 in AMPAC v. 6)
c                                   !
c    %           Nscratch = 3)      !      and a # of scratch files used
c
c      integer loguni(11)                        ! logical unit numbers
c    %     /5,6,9,10,11,12,13,16,20,4,4/
c
c      integer logunt_scr(Nscratch) /2,7/     ! scratch units
c
c       local variables
c
       logical ajar, living
c
                              ! First
                              ! we are closing whatever is opened
        do j=1,Nfiles-1
c
         i = loguni(j)
c
         inquire(unit=i,opened=ajar)  ! checking the status
c
         if (ajar) then
                      ! this one was opened
c
           close(unit=i)      ! so it has be closed ...
         end if
c
        end do                ! loop checking regular channels ends here
c
                              ! now scratch files
        do j=1,Nscratch
c
         i = luscr(j)
c
         inquire(unit=i,opened=ajar)  ! checking the status
         if (ajar) close(unit=i)       ! killing when opened
c
        end do                ! end killing scratch files
c
                              ! now, one good final stroke ....
c
      stop ' Greetings from your EXECUTIONER !'
c
      return    ! this is put here to make some compilers happy
c
      end
