szaghi / FLAP

Fortran command Line Arguments Parser for poor people
151 stars 34 forks source link

No error control parsing boolean values #9

Closed victorsndvg closed 9 years ago

victorsndvg commented 9 years ago

Hello Stefano,

I was checking some features of FLAP and it's a great tool, i'm sure that will be useful for us :)

Through flap_test, I have seen that in some lines when a logical is expected by FLAP there is no error handling. For example if you runl flap_test with the following arguments an error arises:

$ flap_test/FLAP_TEST -s 'asdf' --boolean_val 0 +--> flap_test, a testing program for FLAP library +--> Parsing Command Line Arguments forrtl: severe (59): list-directed I/O syntax error, unit -5, file Internal List-Directed Read ... FLAP_TEST 0000000000411D54 data_type_command 289 ... ...

The error references the following line: https://github.com/szaghi/FLAP/blob/master/src/Data_Type_Command_Line_Interface.f90#L289

A proposal to handle this error might be to replace that line with:

   read(cla%val,*,iostat=error)val
   if(error) write(stderr,'(A)')prefd//' Error: cannot convert "'// &
                  trim(adjustl(cla%val))//'" of CLA "'//cla%switch//'" to boolean.'

Maybe you will find this change useful.

Best regards, Víctor.

szaghi commented 9 years ago

Dear Victor,

you are right. The error trapping algorithm is presently very trivial and there is big room for improving this algorithm.

Feel free to fork FLAP repo, do your great enhancements and commit a pull request. I will very happy to accept your pull requests.

For this specific patch I add it very soon, I hope before tonight. Maybe, I can try to improve the casting of also other types (numbers should be already handled by IR_Precision, but I am not sure).

Thank you for your help.

victorsndvg commented 9 years ago

Dear Stefano,

If I keep working with FLAP, I will be happy to collaborate with the project, but at the moment I'm testing the tool, and I can't promise anything ;)

Thanks :+1: Víctor

szaghi commented 9 years ago

Dear Victor,

your new release has been uploaded (0.0.3).

Note that with respect the older one, many things have been changed:

I have added you to the list of contributors.

See you soon.