Closed gautam-404 closed 5 months ago
You are great! Thank you for working on this.
Unfortunately there seems to be a bug. When I call shmesa test
I get:
...
>>> test: shmesa change
SHMESA> DEBUG: Calling shmesa change with arguments: inlist_project pgstar_flag .false.
SHMESA> DEBUG: SHMESA> BACKING UP: inlist_project inlist_project.bak
SHMESA> DEBUG: Calling shmesa change with arguments: inlist_project initial_mass 1.2 Z 0.01 Zbase 0.01
SHMESA> DEBUG: SHMESA> BACKING UP: inlist_project inlist_project.bak
Error: Parameter 'Z' not found in the inlist 'inlist_project'.
SHMESA> DEBUG: SHMESA> RESTORING: inlist_project
Does shmesa test
work on your machine?
Oh actually this might be a problem with the tester rather than with your fix. Before it tried to change an inlist parameter Z
which doesn't exist. Normal shmesa
just doesn't make a change whereas this fix causes it to not go through. It's fine with it throwing an error though. In that case we should just change the test to have the proper initial_z
rather than just Z
then.
Thanks for pointing that out. This should work now.
I am wondering if it is worth exploring the possibility to include functions like shmesa_set
, shmesa_rm
, shmesa_get
to add, remove or echo inlist parameters.
I've previously implemented this with Python. I am not sure if this is required or will be useful. Thoughts?
Yes, please do! I think those would be really great additions. The only gotcha I can think of is taking care of getting the right namelist group.
The problem of identifying nameless groups is not trivial but it's doable. You can look at the source for MesaScript to see how it's done there (in MesaScript, you don't need to specify namelists; it handles sorting them for you). It might be hard to reproduce in bash
alone, though. If I recall correctly, there is exactly one control that lives in multiple namelist groups. Maybe its logs_directory
that is shared between binary_controls
and controls
, but I could be mistaken.
I have achieved the desired results here. But I guess Python does make things easier. Doing the same with shell script is going to be way more challenging.
Yes having dependencies is tough because then we have to support them - even sed
isn't as cross-platform as I had thought 😂
But I just realized we can do all of these in a pretty straightforward way:
shmesa add
can be done if we just specify the group name and then add the parameter right after it. Then we can grep for e.g. &controls
and put it as the first param in there. Syntax can be shmesa add inlist group paramter value
, e.g., shmesa add inlist controls time_delta_coeff 1
shmesa get
can be a simple grep
shmesa remove
could just add a !
in front of the parameter. It would comment out all such instances which is bad if the same parameter name appears in multiple groups, but as Bill said there's only one example of that, so I think we could live with it... Alternatively it could also require specifying the group name, then it's doable with regex.
fix for issue #661