def write_config(np_min, np_max, nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, tpn, dnpexnpey, dnxny, poisfft, switch, temperton, mlt_grid, spectr): #from configparser import ConfigParser # windows from ConfigParser import ConfigParser # Linux # if __name__ == "__main__": cfg = ConfigParser() cfg.add_section("processor_topology") cfg.set("processor_topology", "np_min", np_min) cfg.set("processor_topology", "np_max", np_max) cfg.set("processor_topology", "tasks_per_node", tpn) cfg.set("processor_topology", "dnpexnpey", dnpexnpey) cfg.set("processor_topology", "dnxny", dnxny) cfg.add_section("numerical_grid") cfg.set("numerical_grid", "nx_min", nx_min) cfg.set("numerical_grid", "nx_max", nx_max) cfg.set("numerical_grid", "ny_min", ny_min) cfg.set("numerical_grid", "ny_max", ny_max) cfg.set("numerical_grid", "nz_min", nz_min) cfg.set("numerical_grid", "nz_max", nz_max) cfg.add_section("method") cfg.set("method", "poisfft", poisfft) cfg.set("method", "switch", switch) cfg.set("method", "temperton", temperton) cfg.set("method", "mlt_grid", mlt_grid) cfg.set("method", "spectr", spectr) with open(".palm_gf_config", "w") as configfile: cfg.write(configfile) def read_config(): #from configparser import ConfigParser # windows from ConfigParser import ConfigParser # Linux cfg = ConfigParser() cfg.read(".palm_gf_config") np_min = cfg.get("processor_topology", "np_min") np_max = cfg.get("processor_topology", "np_max") tpn = cfg.get("processor_topology", "tasks_per_node") dnpexnpey = cfg.get("processor_topology", "dnpexnpey") dnxny = cfg.get("processor_topology", "dnxny") nx_min = cfg.get("numerical_grid", "nx_min") nx_max = cfg.get("numerical_grid", "nx_max") ny_min = cfg.get("numerical_grid", "ny_min") ny_max = cfg.get("numerical_grid", "ny_max") nz_min = cfg.get("numerical_grid", "nz_min") nz_max = cfg.get("numerical_grid", "nz_max") poisfft = cfg.get("method", "poisfft") switch = cfg.get("method", "switch") temperton = cfg.get("method", "temperton") mlt_grid = cfg.get("method", "mlt_grid") spectr = cfg.get("method", "spectr") 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