def generate_jacobians(argdict):

    # Add fixed values to argument dictionary
    dict2 = {'-driver' : 'llg',
            '-ms-method' : 'disabled',
            '-output-jac' : 'always',
            '-solver' : 'gmres',
            '-prec' : 'amg',
            '-doc-interval' : '0'}
    argdict.update(dict2)

    # Get the arguments as a list
    arglist, binary_path, _ = mm.argdict2list(argdict)

    # Make sure the output dir exists and is clean
    outdir = argdict['-outdir']
    mm.cleandir(outdir)

    # Run the driver with the given arguments
    err_code = mm.run_driver(arglist, outdir)

    # Return sucess/failure
    if err_code != 0:
        print("FAILED", ' '.join(arglist))
        return False
    else:
        return True
def generate_jacobians(argdict):

    # Add fixed values to argument dictionary
    dict2 = {
        "-driver": "llg",
        "-ms-method": "disabled",
        "-output-jac": "always",
        "-solver": "gmres",
        "-prec": "amg",
        "-doc-interval": "0",
    }
    argdict.update(dict2)

    # Get the arguments as a list
    arglist, binary_path, _ = mm.argdict2list(argdict)

    # Make sure the output dir exists and is clean
    outdir = argdict["-outdir"]
    mm.cleandir(outdir)

    # Run the driver with the given arguments
    err_code = mm.run_driver(arglist, outdir)

    # Return sucess/failure
    if err_code != 0:
        print("FAILED", " ".join(arglist))
        return False
    else:
        return True
def selftestrun(argdict):

    outdir = argdict.get("-outdir")
    if outdir is None:
        outdir = pjoin("Validation", argdict['-ts'] + str(argdict.get('-ms-method')))
        argdict['-outdir'] = outdir

    arglist, _, _ = mm.argdict2list(argdict)

    mm.cleandir(outdir)
    flag = mm.run_driver(arglist, outdir)

    try:
        data = mm.parse_trace_file(pjoin(outdir, "trace"))
    except IOError:
        data = None

    return data, outdir, flag
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument('parameter_file')
    args = parser.parse_args()

    with open(args.parameter_file, 'r') as pfile:
        args_file = ast.literal_eval(pfile.read())

    try:
        args_dict = args_file[0]
        extra = list(args_file[1:])
    except KeyError:
        args_dict = args_file
        extra = None

    argdicts = sum([mm.generate_argdicts(args_dict, extra_args_dicts=e) for e in extra], [])

    arglists, _, _ = utils.unzip([mm.argdict2list(a) for a in argdicts])

    for a in arglists:
        print("./driver", ' '.join(a), "\n")

    return 0