OPM / opm-parser

http://www.opm-project.org
11 stars 44 forks source link

Unknown keywords #1136

Closed TobiasRitschel closed 6 years ago

TobiasRitschel commented 6 years ago

Hi

I am using the OPM Parser module to read eclipse decks into my code. I have a deck that describes a compositional model. When I run my code, I get the following type of error (here the CNAMES keyword is causing trouble)

std reported error: PARSE_UNKNOWN_KEYWORD: Keyword CNAMES not recognized.

As far as I can see, it is the constructor that causes trouble. I have attached a zipped folder with a minimal example that produces the error.

My question is: is there a way that I can get to read these keywords with OPM Parser? Can I for instance "add" them myself?

Best regards Tobias Ritschel

UnknownKeywordsMWE.zip

For completeness: If I move any of the following keywords up before CNAMES, it gives similar errors EOS STONE2 BIC ACF PCRIT TCRIT VCRIT

joakim-hove commented 6 years ago

My question is: is there a way that I can get to read these keywords with OPM Parser? Can I for instance "add" them myself?

Yes - hopefully you can get past this. The best solution is to just add the necessary Json files:

  1. Read about the Json format used for keywords here

  2. Add the Json file in the appropriate location, e.g. CNAMES should go here.

  3. Add the new keyword files in the list.

  4. Recompile

If this works for you - please make a Pull Request with the new keywords.

Alternatively you can use the ParseContext functionality to suppress the error handling - however be aware that this is quite risky; the moment you start ignoring unknown keywords the internal state of parser becomes quite fragile - and the chance of subsequent hard failure is quite high

TobiasRitschel commented 6 years ago

Thank you for the quick response. This was the type of solution I was hoping for. I too prefer not to turn off error handling.

I am having trouble getting the parser to recognize the keywords though. I have tried with the keyword EOS because it is fairly simple. I have downloaded the newest version of OPM Parser with

git clone https://github.com/OPM/opm-parser.git

(I also had to install libecl). I have created a file opm-parser/lib/eclipse/share/keywords/001_Eclipse300/E/EOS which contains

{
  "name": "EOS",
  "sections": ["PROPS"],
  "size": 1,
  "items": [
    {"name" : "EQUATION_OF_STATE" , "value_type" : "STRING"}
  ]
}

and I have added the line

001_Eclipse300/E/EOS

to opm-parser/lib/eclipse/share/keyword_list.cmake. Then I have deleted the previous local OPM parser build folder and the installed folders /usr/local/include/opm/parser and /usr/local/lib/dunecontrol/opm-parser. Next, I have reinstalled with

mkdir build
cd build
cmake ..
make -j 7
sudo make install

and recompiled my own code, but I still get

std reported error: PARSE_UNKNOWN_KEYWORD: Keyword EOS not recognized.

Is there something in this approach that is insufficient?

Note: Other users on the same machine have local versions of OPM Common and OPM Parser. Could this cause trouble?

joakim-hove commented 6 years ago

What you have done seems 100 % correct - until proven otherwise my hunch would be that your application is picking up a wrong version of the opm-parser library.

TobiasRitschel commented 6 years ago

You were right about that.

My code is a Dune module and I was able to check that CMake links my code against /usr/local/lib/x86_64-linux-gnu/libopmparser.so (which linked to libopmparser.so.2017.04 in the same folder). I had not deleted that file (and it was last modified in July).

I have now repeated the steps in the above post and successfully read the EOS keyword.

I'm closing the issue, but just to be sure: When I want to make a pull request, should I do the following from the opm-parser directory

  1. delete the build folder
  2. push my changes with git push https://github.com/OPM/opm-parser.git master
  3. request a pull with git request-pull master https://github.com/OPM/opm-parser.git master

or is it easier (or less error-prone) to use Githubs pull request functionality?

akva2 commented 6 years ago

you cannot push to the main repo. fork opm-parser to your account, push to your repo, then request a PR. standard github procedure.

joakim-hove commented 6 years ago

I have now repeated the steps in the above post and successfully read the EOS keyword.

I am glad to hear - it has been our ambition that barrier to make such changes should be as low as possible. I am looking forward to your PR.

TobiasRitschel commented 6 years ago

@akva2: Thanks, I'm fairly new to GitHub.

@joakim-hove: I think the current approach is quite fine. Especially because you get informative errors when the keywords are formatted inappropriately. It also makes it easier to divide the task of getting keywords into the system amongst users.

Anyway, thanks for the help.