code: def createfuncwrapper(rout, signature=0):
      assert isfunction(rout)
  
      extra_args = []
      vars = rout["vars"]
      for a in rout["args"]:
          v = rout["vars"][a]
          for i, d in enumerate(v.get("dimension", [])):
              if d == ":":
                  dn = "f2py_%s_d%s" % (a, i)
                  dv = dict(typespec="integer", intent=["hide"])
                  dv["="] = "shape(%s, %s)" % (a, i)
                  extra_args.append(dn)
                  vars[dn] = dv
                  v["dimension"][i] = dn
      rout["args"].extend(extra_args)
      need_interface = bool(extra_args)
  
      ret = [""]
  
      def add(line, ret=ret):
          ret[0] = "%s\n      %s" % (ret[0], line)
  
      name = rout["name"]
      fortranname = getfortranname(rout)
      f90mode = ismoduleroutine(rout)
      newname = "%sf2pywrap" % (name)
  
      if newname not in vars:
          vars[newname] = vars[name]
          args = [newname] + rout["args"][1:]
      else:
          args = [newname] + rout["args"]
  
      l = var2fixfortran(vars, name, newname, f90mode)
      if l[:13] == "character*(*)":
          if f90mode:
              l = "character(len=10)" + l[13:]
          else:
              l = "character*10" + l[13:]
          charselect = vars[name]["charselector"]
          if charselect.get("*", "") == "(*)":
              charselect["*"] = "10"
      sargs = ", ".join(args)
      if f90mode:
          add(
              "subroutine f2pywrap_%s_%s (%s)"
              % (rout["modulename"], name, sargs)
          )
          if not signature:
              add(
                  "use %s, only : %s"
                  % (rout["modulename"], fortranname)
              )
      else:
          add("subroutine f2pywrap%s (%s)" % (name, sargs))
          if not need_interface:
              add("external %s" % (fortranname))
              l = l + ", " + fortranname
      if need_interface:
          for line in rout["saved_interface"].split("\n"):
              if line.lstrip().startswith("use "):
                  add(line)
  
      args = args[1:]
      dumped_args = []
      for a in args:
          if isexternal(vars[a]):
              add("external %s" % (a))
              dumped_args.append(a)
      for a in args:
          if a in dumped_args:
              continue
          if isscalar(vars[a]):
              add(var2fixfortran(vars, a, f90mode=f90mode))
              dumped_args.append(a)
      for a in args:
          if a in dumped_args:
              continue
          if isintent_in(vars[a]):
              add(var2fixfortran(vars, a, f90mode=f90mode))
              dumped_args.append(a)
      for a in args:
          if a in dumped_args:
              continue
          add(var2fixfortran(vars, a, f90mode=f90mode))
  
      add(l)
  
      if need_interface:
          if f90mode:
              # f90 module already defines needed interface
              pass
          else:
              add("interface")
              add(rout["saved_interface"].lstrip())
              add("end interface")
  
      sargs = ", ".join([a for a in args if a not in extra_args])
  
      if not signature:
          if islogicalfunction(rout):
              add(
                  "%s = .not.(.not.%s(%s))"
                  % (newname, fortranname, sargs)
              )
          else:
              add("%s = %s(%s)" % (newname, fortranname, sargs))
      if f90mode:
          add(
              "end subroutine f2pywrap_%s_%s"
              % (rout["modulename"], name)
          )
      else:
          add("end")
      return ret[0]
  
imports: from __future__ import division, absolute_import, print_function
  import copy
  from .auxfuncs import getfortranname, isexternal, isfunction, isfunction_wrap, isintent_in, isintent_out, islogicalfunction, ismoduleroutine, isscalar, issubroutine, issubroutine_wrap, outmess, show
label_desc: Use image node_id 2 for calling a global function with example usage: createfuncwrapper(rout, signature) and returns: ret