      subroutine str2int(str,ival)

      integer*4 ival
      integer ipos(20), num_int
      character*(*) str
      character*1 symbol

      num_char=len(str)

      num_int=0

      do i=1,num_char

         symbol=str(i:i)
	 if (symbol.eq.' ') goto 10

         num_int=num_int+1

	 if (symbol.eq.'0') ipos(num_int)=0
	 if (symbol.eq.'1') ipos(num_int)=1
	 if (symbol.eq.'2') ipos(num_int)=2
	 if (symbol.eq.'3') ipos(num_int)=3
	 if (symbol.eq.'4') ipos(num_int)=4
	 if (symbol.eq.'5') ipos(num_int)=5
	 if (symbol.eq.'6') ipos(num_int)=6
	 if (symbol.eq.'7') ipos(num_int)=7
	 if (symbol.eq.'8') ipos(num_int)=8
	 if (symbol.eq.'9') ipos(num_int)=9
10       continue
	 enddo

      ival=0
      do i=1,num_int
         ipower=num_int-i
         ival=ival+ipos(i)*10**ipower
	 enddo

      return
      end
