View Issue Details

IDProjectCategoryView StatusLast Update
0002252OpenFOAMBugpublic2016-09-23 10:37
ReporterKateEisenhower Assigned Tohenry  
PrioritylowSeveritytextReproducibilityalways
Status closedResolutionno change required 
PlatformallOSallOS Versionall
Summary0002252: foamToVTK error message easy to be misunderstood
DescriptionfoamToVTK -fields p
yields
--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or '(', found on line 0 the word 'p'

where it should say something like
--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or ''(p)'', found on line 0 the word 'p'
in my opinion.

or

--> FOAM FATAL IO ERROR:
the field name has to be wrapped in apostrophes and brackets, e. g. '(p)'
Steps To ReproducefoamToVTK -fields p
Additional InformationIn my opinion the error message is wrong.

incorrect first token, expected <int> or ''', found on line 0 the word 'p'
would be correct formally because obviously OpenFoam expects an apostrophe before (p).
TagsNo tags attached.

Activities

wyldckat

2016-09-22 11:38

updater   ~0006891

A few more details are needed on how to reproduce the message. More specifically, which tutorial case can be used and what commands were used before using foamToVTK?

henry

2016-09-22 12:08

manager   ~0006892

The error message is generated by the HashTable input parser which expects either the number of elements to be specified on an open-bracket in which case it counts the number of elements. To me the message is clear: you need to provide a list.

If you would prefer error messages to contains more context information they would need to be generated at a higher-level requiring context-specific error checking code to be added at every point where user-input is parsed. This would be an enormous undertaking and probably require exception handling code to be added throughout OpenFOAM. If you are keen to see this added to OpenFOAM please submit patches for review.

henry

2016-09-22 12:27

manager   ~0006893

The alternative to adding significantly to error-checking code is to provide useful and accurate help messages; in the case of 'foamToVTK -help' the following relevant information is provided:

  -fields <wordList>
                    only convert the specified fields - eg '(p T U)'

KateEisenhower

2016-09-22 15:01

reporter   ~0006904

@wyldckat: I don't really understand what you mean. You need to have OF installed and the command has to be given from a case directory. You can use any tutorial case you want.

@henry: I agree to most of the things you say. And I don't want to nitpick. For me, the help message is wrong too. In my opinion it should say
  -fields <wordList>
                    only convert the specified fields - eg ''(p T U)''

I just want to help and I really appreciate all the effort both of you are contributing in oder to make OF such a wonderful product!

wyldckat

2016-09-22 16:36

updater   ~0006906

@KateEisenhower: Sorry, I didn't remember that the "-fields" option would complain straight away, regardless of the case and state of the case. It looked at first to me that the problem was file related, not due to the passed argument.

As for the suggestion you made: Why the double quotes?
Wont it be more confusing to those users who copy-paste what's written in the example?

henry

2016-09-22 16:52

manager   ~0006907

> In my opinion it should say

As Bruno says: Why the double quotes?

Both

foamToVTK -fields "(p)"

and

foamToVTK -fields '(p)'

work fine and in this context single-quotes are more convenient.

KateEisenhower

2016-09-23 10:20

reporter   ~0006910

@wyldckat: You made a good point here.

@henry: When you look at the error message:
--> FOAM FATAL IO ERROR:
incorrect first token, expected <int> or '(', found on line 0 the word 'p'
The synthax is not consistent from my point of view.
In this message we have two cases where quotes are used:

Case 1: '('
The error message is telling me that OF expects a bracket here. But that is not true because in reality OF is expecting first a quote and then a bracket.
How do I know that? Because
foamToVTK -fields '(p)' is working.
foamToVTK -fields (p) is not working.
Hence my conclusion is the error message is wrong because OF really expects a quote first, and not a bracket.

Case 2: 'p'
After I deleted the quotes in my mind, OF tells me that it found the word p which is right because I originally entered
foamToVTK -fields p
So in my opinion this part is correct.

I don't know how I could make that any clearer. Hope you understand what I mean.

Best regards,

Kate

henry

2016-09-23 10:37

manager   ~0006911

> foamToVTK -fields (p) is not working.

Right, this is not an issue with OpenFOAM but with the shell you are using and the way it parses arguments to the application. To parse a list as an argument to OpenFOAM or any other applications you will need to put quotes around it if that is required by the shell you are using.

Issue History

Date Modified Username Field Change
2016-09-22 10:52 KateEisenhower New Issue
2016-09-22 11:38 wyldckat Note Added: 0006891
2016-09-22 12:08 henry Note Added: 0006892
2016-09-22 12:27 henry Note Added: 0006893
2016-09-22 15:01 KateEisenhower Note Added: 0006904
2016-09-22 16:36 wyldckat Note Added: 0006906
2016-09-22 16:52 henry Note Added: 0006907
2016-09-22 23:06 henry Assigned To => henry
2016-09-22 23:06 henry Status new => closed
2016-09-22 23:06 henry Resolution open => no change required
2016-09-23 10:20 KateEisenhower Status closed => feedback
2016-09-23 10:20 KateEisenhower Resolution no change required => reopened
2016-09-23 10:20 KateEisenhower Note Added: 0006910
2016-09-23 10:37 henry Status feedback => closed
2016-09-23 10:37 henry Resolution reopened => no change required
2016-09-23 10:37 henry Note Added: 0006911