1 | def write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey, dnxny, poisfft, switch, |
---|
2 | temperton, mlt_grid, spectr): |
---|
3 | #from configparser import ConfigParser # windows |
---|
4 | from ConfigParser import ConfigParser # Linux |
---|
5 | |
---|
6 | # if __name__ == "__main__": |
---|
7 | cfg = ConfigParser() |
---|
8 | |
---|
9 | cfg.add_section("processor_topology") |
---|
10 | cfg.set("processor_topology", "np_min", np_min) |
---|
11 | cfg.set("processor_topology", "np_max", np_max) |
---|
12 | cfg.set("processor_topology", "tasks_per_node", tpn) |
---|
13 | cfg.set("processor_topology", "dnpexnpey", dnpexnpey) |
---|
14 | cfg.set("processor_topology", "dnxny", dnxny) |
---|
15 | |
---|
16 | cfg.add_section("numerical_grid") |
---|
17 | cfg.set("numerical_grid", "nx_min", nx_min) |
---|
18 | cfg.set("numerical_grid", "nx_max", nx_max) |
---|
19 | cfg.set("numerical_grid", "ny_min", ny_min) |
---|
20 | cfg.set("numerical_grid", "ny_max", ny_max) |
---|
21 | cfg.set("numerical_grid", "nz_min", nz_min) |
---|
22 | cfg.set("numerical_grid", "nz_max", nz_max) |
---|
23 | |
---|
24 | cfg.add_section("method") |
---|
25 | cfg.set("method", "poisfft", poisfft) |
---|
26 | cfg.set("method", "switch", switch) |
---|
27 | cfg.set("method", "temperton", temperton) |
---|
28 | cfg.set("method", "mlt_grid", mlt_grid) |
---|
29 | cfg.set("method", "spectr", spectr) |
---|
30 | |
---|
31 | with open(".palm_gf_config", "w") as configfile: |
---|
32 | cfg.write(configfile) |
---|
33 | |
---|
34 | |
---|
35 | def read_config(): |
---|
36 | #from configparser import ConfigParser # windows |
---|
37 | from ConfigParser import ConfigParser # Linux |
---|
38 | |
---|
39 | cfg = ConfigParser() |
---|
40 | |
---|
41 | cfg.read(".palm_gf_config") |
---|
42 | np_min = cfg.get("processor_topology", "np_min") |
---|
43 | np_max = cfg.get("processor_topology", "np_max") |
---|
44 | tpn = cfg.get("processor_topology", "tasks_per_node") |
---|
45 | dnpexnpey = cfg.get("processor_topology", "dnpexnpey") |
---|
46 | dnxny = cfg.get("processor_topology", "dnxny") |
---|
47 | |
---|
48 | nx_min = cfg.get("numerical_grid", "nx_min") |
---|
49 | nx_max = cfg.get("numerical_grid", "nx_max") |
---|
50 | ny_min = cfg.get("numerical_grid", "ny_min") |
---|
51 | ny_max = cfg.get("numerical_grid", "ny_max") |
---|
52 | nz_min = cfg.get("numerical_grid", "nz_min") |
---|
53 | nz_max = cfg.get("numerical_grid", "nz_max") |
---|
54 | |
---|
55 | poisfft = cfg.get("method", "poisfft") |
---|
56 | switch = cfg.get("method", "switch") |
---|
57 | temperton = cfg.get("method", "temperton") |
---|
58 | mlt_grid = cfg.get("method", "mlt_grid") |
---|
59 | spectr = cfg.get("method", "spectr") |
---|
60 | |
---|
61 | return np_min, np_max, tpn, dnpexnpey, dnxny, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, poisfft, switch, temperton, mlt_grid, spectr |
---|