      subroutine element(natom,string,natomtype)

c  this subroutine written by alain st-amant of the department of
c  pharmaceutical chemistry, university of california, san francisco.
c  all rights reserved.  this is part of the DeFT project.

      character atomic_symbol(0:105)*2,symbol*2

      character string(*)

      dimension natomtype(*)

      data atomic_symbol/ 'xx', 'h ', 'he', 'li', 'be', 'b ', 'c ',
     &                    'n ', 'o ', 'f ', 'ne', 'na', 'mg', 'al',
     &                    'si', 'p ', 's ', 'cl', 'ar', 'k ', 'ca',
     &                    'sc', 'ti', 'v ', 'cr', 'mn', 'fe', 'co',
     &                    'ni', 'cu', 'zn', 'ga', 'ge', 'as', 'se',
     &                    'br', 'kr', 'rb', 'sr', 'y ', 'zr', 'nb',
     &                    'mo', 'tc', 'ru', 'rh', 'pd', 'ag', 'cd',
     &                    'in', 'sn', 'sb', 'te', 'i ', 'xe', 'cs',
     &                    'ba', 'la', 'ce', 'pr', 'nd', 'pm', 'sm',
     &                    'eu', 'gd', 'tb', 'dy', 'ho', 'er', 'tm',
     &                    'yb', 'lu', 'hf', 'ta', 'w ', 're', 'os',
     &                    'ir', 'pt', 'au', 'hg', 'tl', 'pb', 'bi',
     &                    'po', 'at', 'rn', 'fr', 'ra', 'ac', 'th',
     &                    'pa', 'u ', 'np', 'pu', 'am', 'cm', 'bk',
     &                    'cf', 'es', 'fm', 'md', 'no', 'lw', 'ku',
     &                    'ha'/

      symbol(1:1)=string(1)

      if(((ichar(string(2)).ge.ichar('0')).and.
     &    (ichar(string(2)).le.ichar('9'))).or.
     &    (ichar(string(2)).eq.ichar(' '))) then
                                                  symbol(2:2)=' '
                                            else
                                                  symbol(2:2)=string(2)
                                            endif

      call makelowercase(symbol,2)

      natomtype(natom)=666

      do 1001 i=0,105
 1001 if(symbol.eq.atomic_symbol(i)) natomtype(natom)=i

      if(natomtype(natom).eq.666) stop 'bad atomic symbol'

      return
      end
