docs: def convpar(p):
      """
      Convert a parameter set from convenient Python dictionary to the format
      expected by the Fortran kernels.
      """
  
      if 'el' not in p:
          return p
  
      els = p['el']
      nel = len(els)
  
      q = { }
      for name, values in p.items():
  
          if isinstance(values, dict):
              # This is a dictionary. We need to first understand what it is and
              # then convert to the appropriate list
              m = 0
              for itype, value in values:
                  if itype[0] == '_':
                      continue
                  # Ask ASE to turn this into a list of symbols
                  syms = string2symbols(itype)
                  # Now turn this into a list of indices
                  nums = [ els.index(sym) for sym in syms ]
                  # We need to know the maximum number of symbols
                  m = max(m, nums)
  
              default = 0.0
              if '__default__' in values:
                  default = values['__default__']
              if m == 2:
                  # These are pair indices
                  new_values = [ default ]*pair_index(nel,nel,nel)
              elif m == 3:
                  # These are triplet indices
                  new_values = [ default ]*triplet_index(nel,nel,nel,nel)
              else:
                  raise RuntimeError("Parameter '%s' appears to involve " \
                                     "interaction between %i atoms. Do not know "\
                                     "how to handle this." % ( name, nel ))
  
              for itype, value in values:
                  if itype[0] == '_':
                      continue
                  # Ask ASE to turn this into a list of symbols
                  syms = string2symbols(itype)
                  # Now turn this into a list of indices
                  nums = [ els.index(sym) for sym in syms ]
                  if len(nums) == m:
                      # Set value
                      if m == 2:
                          i,j = nums
                          new_values[pair_index(i,j,nel)] = value
                      elif m == 3:
                          i,j,k = nums
                          new_values[triple_index(i,j,k,nel)] = value
                  else:
                      # We have fewer values than we need
                      if m == 3 and len(nums) == 1:
                          [k] = nums
                          for i in range(nel):
                              for j in range(nel):
                                  # There is six possible permutations
                                  new_values[triple_index(i,j,k,nel)] = value
                                  new_values[triple_index(i,k,j,nel)] = value
                                  new_values[triple_index(k,j,i,nel)] = value
                                  new_values[triple_index(j,k,i,nel)] = value
                                  new_values[triple_index(k,i,j,nel)] = value
                                  new_values[triple_index(i,j,k,nel)] = value
                      elif m == 3 and len(nums) == 2:
                          [i,j] = nums
                          for k in range(nel):
                              # There is six possible permutations
                              new_values[triple_index(i,j,k,nel)] = value
                              new_values[triple_index(i,k,j,nel)] = value
                              new_values[triple_index(k,j,i,nel)] = value
                              new_values[triple_index(j,k,i,nel)] = value
                              new_values[triple_index(k,i,j,nel)] = value
                              new_values[triple_index(i,j,k,nel)] = value
                      else:
                          raise RuntimeError("Parameter '%s' appears to involve " \
                                             "interaction between %i atoms, but " \
                                             "only %i elements were provied. Do " \
                                             "not know how to handle this." \
                                             % ( name, nel, len(nums) ))
              values = new_values
  
          q[name] = values
      return q