import re


def collect_subroutine_calls(lines,ifbranch_lines):
   """
   Collect a dictionary of all subroutine call instances. In the source code
   on entry the "subroutine call" is given in the form of a function call, e.g.
   t5 = nwxc_c_Mpbe(rhoa,0.0d+0,gammaaa,0.0d+0,0.0d+0)
   we need to know the "nwxc_c_Mpbe(rhoa,0.0d+0,gammaaa,0.0d+0,0.0d+0)" part.
   The key in the dictionary is going to be the variable name (i.e. "t5") as we
   will have to replace those variable instances with an array element 
   reference.
   The resulting dictionary is returned.
   """
   (lineno_start,lineno_end) = ifbranch_lines
   dict = {}
   pattern = re.compile("nwxc")
   line = lineno_start
   while line <= lineno_end:
      if pattern.search(lines[line]):
         aline = lines[line]
         aline = aline.split(" = ")
         key   = aline[0].lstrip()
         dict[key] = aline[1]
      line += 1
   return dict