-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f62f1d
commit 2c706bf
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import sys | ||
import copy | ||
import unittest | ||
import subprocess | ||
import numpy as np | ||
import pyphare.pharein as ph | ||
from pyphare.simulator.simulator import Simulator | ||
from tests.simulator import test_restarts | ||
from tests.diagnostic import dump_all_diags | ||
|
||
output_dir = "phare_data_gen/" | ||
|
||
|
||
def run_restartable_data_sim(): | ||
from tests.simulator import test_init_from_restart as restartable_sim | ||
|
||
"""uses params from tests_restarts.py""" | ||
out = output_dir + "/tests/simulator/test_init_from_restart" | ||
simput = copy.deepcopy(test_restarts.simArgs) | ||
simput["restart_options"]["dir"] = out | ||
simput["restart_options"]["timestamps"] = restartable_sim.timestamps | ||
simput["diag_options"]["options"]["dir"] = out | ||
sim = ph.Simulation(**simput) | ||
dump_all_diags( | ||
test_restarts.setup_model().populations, timestamps=restartable_sim.timestamps | ||
) | ||
Simulator(sim).run() | ||
|
||
|
||
def launch(fn, n=5): | ||
"""Launch secondary process to run first simulation to avoid initalizing MPI now""" | ||
cmd = f"mpirun -n {n} python3 -O {__file__} {fn}" | ||
print(cmd) | ||
try: | ||
p = subprocess.run(cmd.split(" "), check=True, capture_output=True) | ||
except subprocess.CalledProcessError as e: | ||
print("CalledProcessError", e) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) > 1: | ||
globals()[sys.argv[1]]() | ||
else: | ||
for k in [k for k in list(globals().keys()) if k.startswith("run_")]: | ||
launch(k) | ||
# | ||
# tar czf phare_data_gen.tar.xz phare_data_gen | ||
# mc put phare_data_gen.tar.xz minio/phare/phare_data_gen.tar.xz --insecure |