source: palm/trunk/SCRIPTS/palm_gf_files/palm_gf_conf.py @ 4882

Last change on this file since 4882 was 4869, checked in by schwenkel, 4 years ago

update palm_gf to python3

File size: 2.6 KB
Line 
1#!/usr/bin/env python
2# windows
3from configparser import ConfigParser
4# linux
5#from configparser import configparser
6import os
7
8cfg = ConfigParser()
9
10
11def cfg_write(nx_min, nx_max, ny_min, ny_max, nz_min, nz_max, np_min, np_max, tpn,
12              poisfft, switch, temperton, mlt_grid, spectr, dnxny, dpxpy, dpxpy_dev):
13    # receives parameters from palm_gf and creates/updates .ini file
14    if os.path.exists('./palm_gf_config.ini') is False:
15        cfg.add_section("Numerical Grid")
16        cfg.add_section("Processor Topology")
17        cfg.add_section("Method")
18    else:
19        cfg.read("palm_gf_config.ini")
20
21    cfg.set("Numerical Grid", "nx min", str(nx_min))
22    cfg.set("Numerical Grid", "nx max", str(nx_max))
23    cfg.set("Numerical Grid", "ny min", str(ny_min))
24    cfg.set("Numerical Grid", "ny max", str(ny_max))
25    cfg.set("Numerical Grid", "nz min", str(nz_min))
26    cfg.set("Numerical Grid", "nz max", str(nz_max))
27
28    cfg.set("Processor Topology", "np min", str(np_min))
29    cfg.set("Processor Topology", "np max", str(np_max))
30    cfg.set("Processor Topology", "tasks per node", str(tpn))
31    cfg.set("Processor Topology", "ratio nx/ny", str(dnxny))
32    cfg.set("Processor Topology", "ratio npex/npey", str(dpxpy))
33    cfg.set("Processor Topology", "ratio npex/npey tolerance", str(dpxpy_dev))
34
35    cfg.set("Method", "poisfft", str(poisfft))
36    cfg.set("Method", "switch", str(switch))
37    cfg.set("Method", "temperton", str(temperton))
38    cfg.set("Method", "multigrid", str(mlt_grid))
39    cfg.set("Method", "spectra", str(spectr))
40
41    with open("./palm_gf_config.ini", 'w') as cfgfile:
42        cfg.write(cfgfile)
43
44    return True
45
46
47def cfg_read():
48    # reads the .ini File and returns all parameters in a list
49    cfg.read("palm_gf_config.ini")
50    return_list = [cfg.get("Numerical Grid", "nx min"), cfg.get("Numerical Grid", "nx max"),
51                   cfg.get("Numerical Grid", "ny min"), cfg.get("Numerical Grid", "ny max"),
52                   cfg.get("Numerical Grid", "nz min"), cfg.get("Numerical Grid", "nz max"),
53                   cfg.get("Processor Topology", "np min"), cfg.get("Processor Topology", "np max"),
54                   cfg.get("Processor Topology", "tasks per node"), cfg.get("Processor Topology", "ratio nx/ny"),
55                   cfg.get("Processor Topology", "ratio npex/npey"),
56                   cfg.get("Processor Topology", "ratio npex/npey tolerance"), cfg.get("Method", "poisfft"),
57                   cfg.get("Method", "switch"), cfg.get("Method", "temperton"), cfg.get("Method", "multigrid"),
58                   cfg.get("Method", "spectra")]
59
60    return return_list
Note: See TracBrowser for help on using the repository browser.