      SUBROUTINE SPACEFIX(cinput,nsp0,nsps,nspf,nsp)

C     SPACEFIX REVEALS BEGINNING AND ENDING SPACES

      character*(*) cinput

      nsps=1
      icharfound=0
      do 55 n0=1,nsp0
       if ( cinput(n0:n0) .eq. ' ' .and. icharfound .ne. 1 ) then
        nsps=nsps+1
       elseif ( cinput(n0:n0) .ne. ' ' ) then
        icharfound=1
       endif
55    continue

      nspf=nsp0
      icharfound=0

      do 65 n0=nsp0,nsps,-1
       if ( cinput(n0:n0) .eq. ' ' .and. icharfound .ne. 1 ) then
        nspf=nspf-1
       elseif ( cinput(n0:n0) .ne. ' ' ) then
        icharfound=1
       endif
65    continue
      nsp=nspf-nsps+1

      return
      end
