def _py_clean(parameter, tab):
    """Returns the code line to clean the output value of the specified parameter.
    """
    if "out" in parameter.direction:
        if parameter.D > 0:
            if ":" in parameter.dimension and ("allocatable" in parameter.modifiers or
                                               "pointer" in parameter.modifiers):
                if parameter.D == 1:
                    clarray = "as_array({0}_o, ({0}_0.value,))".format(parameter.lname)
                else:
                    #We have to reverse the order of the indices because of the way that
                    #fortran orders the array elements. We undo this using a transpose in
                    #the ftypes.as_array() so that the elements are ordered correctly.
                    splice = ', '.join(reversed(["{0}_{1:d}.value".format(parameter.lname, i)
                                                 for i in range(parameter.D)]))       
                    clarray = "as_array({0}_o, ({1}))".format(parameter.lname, splice)

                assign = '{0}result.add("{1}", {2}, {1}_ft)'.format(tab, parameter.lname, clarray)
                fstr = _py_ftype(parameter, tab)
                    
                #For optional out parameters, we won't necessarily have anything to report.
                return _py_check_optional(parameter, tab, [fstr, assign])
            else:
                return '{1}result.add("{0}", {0}_a)'.format(parameter.lname, tab)
        else: #This handles scalar (inout) and (out) variables.
            return '{1}result.add("{0}", {0}_c.value)'.format(parameter.lname, tab)
Returns the code line to clean the output value of the specified parameter.