def METHOD_NAME(method, grid):
    if method == "hf":
        method_stdin = ""
    elif method in METHODS["ricc2"]:
        # Setting geoopt in $ricc2 will make the ricc2 module to produce
        # a gradient.
        # Drop the 'ri'-prefix of the method string.
        geoopt_stdin = f"geoopt {method[2:]} ({geoopt})" if geoopt else ""
        method_stdin = f"""cc
                           freeze
                           *
                           cbas
                           *
                           ricc2
                           {method}
                           list models
                           {geoopt_stdin}
                           list geoopt
                           *
                           *
                        """
    elif method in METHODS["dft_hardcoded"]:
        method_stdin = f"""dft
                           on
                           func
                           {method}
                           grid
                           {grid}
                        """
    # TODO: Handle xcfuncs that aren't defined in define, e.g.
    # new functionals introduced in 7.4 from libxc. ...
    # Maybe the best idea would be to not set the functional here
    # but just turn on DFT and add it to the control file later on.
    elif method in METHODS["dft_libxc"]:
        raise InputError("libxc functionals are not supported right now.")
    return method_stdin