Skip to content

Commit

Permalink
Initial attempt of multi replica
Browse files Browse the repository at this point in the history
  • Loading branch information
hmcezar committed Sep 28, 2023
1 parent 6fe8d4c commit 1ebd479
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 76 deletions.
16 changes: 14 additions & 2 deletions hymd/configure_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def configure_runtime(args_in, comm):
ap.add_argument(
"--destdir", default=".", help="Write output to specified directory"
)
ap.add_argument(
"--replica-dirs", type=str, nargs="+", default=[], help="Directories to store results for each replica"
)
ap.add_argument(
"--seed",
default=None,
Expand Down Expand Up @@ -143,12 +146,21 @@ def configure_runtime(args_in, comm):
type=extant_file,
help="Gmx-like topology file in toml format"
)
ap.add_argument("config", help="Config .py or .toml input configuration script")
ap.add_argument("config", type=extant_file, help="Config .py or .toml input configuration script")
ap.add_argument("input", help="input.hdf5")
args = ap.parse_args(args_in)

# check if we have at least one rank per replica
if comm.Get_size() < len(args.replica_dirs):
raise ValueError("You should have at least one MPI rank per replica.")

# block destdir with replicas
if (len(args.replica_dirs) > 0) and args.destdir != ".":
raise ValueError("You should not specify a destination directory when using replicas.")

if comm.Get_rank() == 0:
os.makedirs(args.destdir, exist_ok=True)

comm.barrier()

# Safely define seeds
Expand Down Expand Up @@ -241,5 +253,5 @@ def extant_file(x):
# Argparse uses the ArgumentTypeError to give a rejection message like:
# error: argument input: x does not exist
raise argparse.ArgumentTypeError("{0} does not exist".format(x))
return x
return os.path.abspath(x)

14 changes: 1 addition & 13 deletions hymd/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,8 @@ def store_static(
creator_group = h5md_group.create_group("creator")
creator_group.attrs["name"] = np.string_("Hylleraas MD")

# Get HyMD version. Also grab the user email from git config if we
# can find it.
# Get HyMD version
creator_group.attrs["version"] = np.string_(get_version())
try:
import git

try:
reader = repo.config_reader()
user_email = reader.get_value("user", "email")
author_group.attrs["email"] = np.string_(user_email)
except:
pass
except:
pass

h5md.particles_group = h5md.file.create_group("/particles")
h5md.all_particles = h5md.particles_group.create_group("all")
Expand Down
Loading

0 comments on commit 1ebd479

Please sign in to comment.