Skip to content

Commit

Permalink
Add option to run legacy input from command line. (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
linusjoonho authored Oct 28, 2023
2 parents 5dd911b + 62ac42b commit 293db7c
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions bin/ipie
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Copyright 2022 The ipie Developers. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,12 +19,9 @@
#!/usr/bin/env python3

import argparse
import json
import sys

from ipie.config import MPI

from ipie.config import config
from ipie.config import config, MPI


def parse_args(args, comm):
Expand All @@ -43,10 +39,12 @@ def parse_args(args, comm):
"""

if comm.rank == 0:
parser = argparse.ArgumentParser(description = __doc__)
parser.add_argument('--gpu', dest='use_gpu', action="store_true",
help='Use GPU.')
parser.add_argument('remaining_options', nargs=argparse.REMAINDER)
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--gpu", dest="use_gpu", action="store_true", help="Use GPU.")
parser.add_argument(
"--legacy", dest="use_legacy", action="store_true", help="Use legacy driver."
)
parser.add_argument("remaining_options", nargs=argparse.REMAINDER)
options = parser.parse_args(args)
else:
options = None
Expand All @@ -60,7 +58,6 @@ def parse_args(args, comm):
return options



def main(input_file):
"""Simple launcher for ipie via input file.

Expand All @@ -72,11 +69,21 @@ def main(input_file):
comm = MPI.COMM_WORLD
options = parse_args(sys.argv[1:], comm)
config.update_option("use_gpu", options.use_gpu)
from ipie.qmc.calc import setup_calculation
(afqmc, comm) = setup_calculation(options.remaining_options[0])
afqmc.run(verbose=True)
afqmc.finalise(verbose=True)
if options.use_legacy:
from ipie.legacy.qmc.calc import get_driver as get_legacy_driver
from ipie.qmc.calc import read_input

input_dict = read_input(options.remaining_options[0], comm)
afqmc = get_legacy_driver(input_dict, comm)
afqmc.run(comm=comm)
afqmc.finalise(comm)
else:
from ipie.qmc.calc import setup_calculation

(afqmc, comm) = setup_calculation(options.remaining_options[0])
afqmc.run(verbose=True)
afqmc.finalise(verbose=True)


if __name__ == '__main__':
if __name__ == "__main__":
main(sys.argv[1])

0 comments on commit 293db7c

Please sign in to comment.