Parsing command line inputs #508
-
|
Hi - is there a recommended way to parse command line inputs in pyamrex? I am currently doing what I show below, but, its not reading all the elements of the list n_cell, only the first element. In fact it treats n_cell as an integer and. not a list. import amrex.space2d as amr
amr.initialize([])
pp = amr.ParmParse("")
pp.addfile("burgers.inp")
n_cell = [64, 64]
print(f"n_cell: {n_cell}")
# _, n_cell = pp.query_int("n_cell")
n_cell = pp.query_int("n_cell")
print(f"n_cell: {n_cell}")
amr.finalize()the input file bugers.inp looks like this: n_cell = 128 128the output of the code is Initializing AMReX (25.11)...
AMReX (25.11) initialized
n_cell: [64, 64]
n_cell: (True, 128)
AMReX (25.11) finalizedAny help is appreciated. THanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
I don't know the plan for the getter and query interface. Currently there is a comment, |
Beta Was this translation helpful? Give feedback.
-
|
That works, Thanks!! |
Beta Was this translation helpful? Give feedback.
-
|
Follow up - how do you query string inputs? There doesnt seem to be a get_string or query_string method available - is there a way to do this? |
Beta Was this translation helpful? Give feedback.
I don't know the plan for the getter and query interface. Currently there is a comment,
// TODO: getters and queriesin the code. Nevertheless, you can work around it by callingpp.query_int("n_cell", 1)to get the second value.