0 votes
asked by (620 points)

I am wondering if there is a simple way to convert an InputGroup into a type Args? Basically I want a single system that contains all the parameters for my code, but I don't want changing the input file to lead to parameters changing mid program. If there is a way to have the InputGroup be locked upon initialization or something, that would be fine too.


1 Answer

0 votes
answered by (44k points)

Hi Nick,
I'm not sure I understand the part of your question about the input parameters changing mid program. I believe when you read in the input file the parameters are set at that point (are read into the InputGroup object), then when you retrieve them they will be whatever they were when the file was read. Are you planning on changing your input file while your program is running? Conceptually that's possible but I would not recommend it.

In terms of how the input.h / InputGroup system relates to Args, they were developed separately so don't really interoperate. At one point I made them have a similar interface so it would be easier to remember how to use them. I did plan to later on make them more interoperable, like having the option to retrieve the input parameters as an Args object. But I had more pressing things so haven't done it. It would be a good project for someone to do and I think would not be too hard; the code for each is relatively straightforward and well written I think.

Best regards,

commented by (620 points)
Hi Miles,

What is I want is for the InputGroup to not change if the file it reads in does later on. As an example look at the following code

    auto inputs = InputGroup("test_input","input");
    auto test = inputs.getString("testvalue");
    cout << test << endl;
    test = inputs.getString("testvalue");
    cout << test << endl;

Now, if during the cin.get() line I change the value of "testvalue" in the input file, the change will appear at the next cout line.

Although I personally don't plan to change the input file mid program, it would be nice to have a guarantee that if the file does change, my code parameters do not.
commented by (44k points)
I see thanks. I don’t think the InputGroup does change the results if the file changes later on. So I believe it already behaves the way you want. Did you have a case where you observed it did not? Thanks
commented by (620 points)
In the code example above. If I were to change the input file at the cin.get() line (this line is only there for a pause so I can change the input file before the next line of code) then when I read from the InputGroup in the next line, I will get the new value, not the original value loaded in when the InputGroup was instantiated.
commented by (44k points)
Hi Nick, I see, thanks for patiently clarifying what you mean. So I would consider this an "enhancement" bug report. I'll file it on our Github ITensor repo as an enhancement we should pursue, and I think it would be straightforward to implement by just 'eagerly' reading in and parsing the whole input file right away rather than 'lazily'.

commented by (620 points)
Sounds great, thank you Miles!
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.