c @(#)chmchg.f 2.1 92/01/06
      subroutine chmchg (chm,iz)
c
c***********************************************************************
c*                                                                     *
cn module: chmchg (L.5)                                                *
c*                                                                     *
cf function: convert from the chemical symbol to the charge            *
cf                              and vice versa                         *
c*                                                                     *
cr called from: library routine                                        *
c*                                                                     *
cm modified input variables:                                           *
cm chm     f.p.    c*4       chemical_symbol                           *
cm iz      f.p.    i         nuclear_charge                            *
c*                                                                     *
cl local variables:                                                    *
cl itemp           i         do_loop_variable                          *
cl lchm            c*4(101)  lower_case_table_of_chemical_symbols      *
cl uchm            c*4(101)  upper_case_table_of_chemical_symbols      *
c*                                                                     *
cs subroutines called:                                                 *
cs    mabort (M.1)                                                     *
c*                                                                     *
c***********************************************************************
cd
cd variable declarations
      character*2 chm
      integer     iz
      integer itemp
cd
cd constant declarations
      character*2 lchm(101),uchm(101)
      data lchm /'h ','he','li','be','b ','c ','n ','o ','f ','ne',
     1           'na','mg','al','si','p ','s ','cl','ar','k ','ca',
     2           'sc','ti','v ','cr','mn','fe','co','ni','cu','zn',
     3           'ga','ge','as','se','br','kr','rb','sr','y ','zr',
     4           'nb','mo','tc','ru','rh','pd','ag','cd','in','sn',
     5           'sb','te','i ','xe','cs','ba','la','ce','pr','nd',
     6           'pm','sm','eu','gd','tb','dy','ho','er','tm','yb',
     7           'lu','hf','ta','w ','re','os','ir','pt','au','hg',
     8           'tl','pb','bi','po','at','rn','fr','ra','ac','th',
     9           'pa','u ','np','pu','am','cm','bk','cf','es','fm',' ' /
      data uchm /'H ','HE','LI','BE','B ','C ','N ','O ','F ','NE',
     1           'NA','MG','AL','SI','P ','S ','CL','AR','K ','CA',
     2           'SC','TI','V ','CR','MN','FE','CO','NI','CU','ZN',
     3           'GA','GE','AS','SE','BR','KR','RB','SR','Y ','ZR',
     4           'NB','MO','TC','RU','RH','PD','AG','CD','IN','SN',
     5           'SB','TE','I ','XE','CS','BA','LA','CE','PR','ND',
     6           'PM','SM','EU','GD','TB','DY','HO','ER','TM','YB',
     7           'LU','HF','TA','W ','RE','OS','IR','PT','AU','HG',
     8           'TL','PB','BI','PO','AT','RN','FR','RA','AC','TH',
     9           'PA','U ','NP','PU','AM','CM','BK','CF','ES','FM',' '/
c$
c     if (nonzero atomic number) then
      if (iz .gt. 0) then
c
c        set chemical_symbol to appropriate symbol
         if (iz .lt. 101) then
            chm = lchm(iz)
         else
            write (6,101) iz
         end if
c
c     else
      else
c
c        loop over chemical elements
         do 10 itemp = 1,100
c
c           if (have chemical_symbol matches table entry) leave loop
            if (chm .eq. lchm(itemp)) go to 20
            if (chm .eq. uchm(itemp)) go to 20
c
c        end loop
10       continue
         write (6,102) chm
         itemp = 101
c
c        set nuclear_charge to do_loop_variable
20       iz = itemp
c
c     end if
      end if
c
      return
c
101   format (/ 'ERROR IN CHMCHG  illegal nuclear_charge = ',i5)
102   format (/ 'ERROR IN CHMCHG  unknown chemical = ',a2)
      end
