import re


def find_max_order_diff(lines,subr_lines):
   """
   Work out the maximum order of differentiation for a given subroutine.
   The maximum order is returned.
   """
   (lineno_start,lineno_end) = subr_lines
   aline = lines[lineno_start]
   orderdiff = 0
   pattern_d2 = re.compile("_d2\(")
   pattern_d3 = re.compile("_d3\(")
   if pattern_d2.search(aline):
      orderdiff = 2
   elif pattern_d3.search(aline):
      orderdiff = 3
   else:
      orderdiff = 1
   return orderdiff