getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Getfem-users] Problem with parameters handling


From: Yves Renard
Subject: Re: [Getfem-users] Problem with parameters handling
Date: Wed, 8 Nov 2006 14:08:14 +0100
User-agent: KMail/1.7.2

Le Lundi 30 Octobre 2006 12:10, Roman Putanowicz a écrit :
> Hi,
>
> I have a problem with setting string parameters from command line:
> I have written this small test program:
>
> #include <ftool.h>
> #include <iostream>
>
> int main(int argc, char *argv[]) {
>   ftool::md_param params;
>   params.add_string_param("MSG", "Foo is not Bar");
>   params.add_real_param("size", 1.0);
>   params.read_command_line(argc, argv);
>   std::cout << params.string_value("MSG") << "\n";
>   std::cout << params.real_value("size") <<  "\n";
>   return 0;
> };
>
> and this is the result of running it with different command line arguments.
>
> jinx:~/programming/c++/getfem/examples/params>./params
> Foo is not Bar
> 1
>
> jinx:~/programming/c++/getfem/examples/params>./params -d size=10.11
> Foo is not Bar
> 10.11
>
> jinx:~/programming/c++/getfem/examples/params>./params -d size=10.11 -d
> MSG='foo'
> terminate called after throwing an instance of 'dal::failure_error'
>   what():  Error in ftool.cc, line 166 :
>   Error reading command line line 1 : Parameter foo not found
>   Abort
>
> So as you can see it fails when trying to set string parameter.
> On the other hand when using parameter file it works all right.
>
> I will look at the source code but maybe some of you will be
> quicker in finding this bug (if this is a bug:).

This is not really a bug. With a command line like 
./params -d size=10.11 -d MSG='foo'
the quotes will be suppressed in argv and the foo variable is searched to make 
the assignment MSG=foo.
To fix this problem, the command line should be written
./params -d size=10.11 -d "MSG='foo'"
for instance.
You have som examples for instance in tests/elastostatic.pl

-- 
Yves.

-------------------------------------------------------------------------
  Yves Renard (address@hidden)       tel : (33) 04.72.43.80.11
  Pole de Mathematiques, INSA de Lyon          fax : (33) 04.72.43.85.29
  Institut Camille Jordan - CNRS UMR 5208
  20, rue Albert Einstein
  69621 Villeurbanne Cedex, FRANCE
  http://math.univ-lyon1.fr/~renard
-------------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]