[Trilinos-Users] strange error setting parameter list
Hoang Giang Bui
hgbk2008 at gmail.com
Tue Apr 9 13:31:57 MDT 2013
Hi Radu
Thanks for your comment but I think this problem related to RTTI conflict
The function Teuchos::ParameterList.get tries to compare the type_info
of the template argument (in this case std::string) with type_info of
the value passed in ("BP")
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(
entry_in.getAny().type() != typeid(T), Exceptions::InvalidParameterType
,"Error! An attempt was made to access parameter \""<<name_in<<"\""
" of type \""<<entry_in.getAny().typeName()<<"\""
"\nin the parameter (sub)list \""<<this->name()<<"\""
"\nusing the incorrect type \""<<TypeNameTraits<T>::name()<<"\"!"
);
In this case both are std::string but the type_info are different. I
search the web for how to align the type_info when linking shared
libraries but found no solution.
BR
Bui
On 04/09/13 21:08, Radu Popescu wrote:
> Sorry,
>
> I meant:
>
> p.set("name", std::string("BP"));
>
> Radu
>
>
> On Tue, Apr 9, 2013 at 9:08 PM, Radu Popescu <i.radu.popescu at gmail.com
> <mailto:i.radu.popescu at gmail.com>> wrote:
>
> Hi there,
>
> Try with:
>
> p.set(std::string("name"), "BP");
>
> I think if you don't construct a std::string explicitly, it will
> be created as a char*
>
> Regards,
> Radu Popescu
>
>
> On Tue, Apr 9, 2013 at 7:13 PM, Hoang Giang Bui
> <hgbk2008 at gmail.com <mailto:hgbk2008 at gmail.com>> wrote:
>
> Hi
>
> I got problem with Teuchos::ParameterList again
>
> At some place in my code I created a ParameterList
>
> Teuchos::ParameterList p;
>
> p.set("name", "BP");
>
> Try to read it back at another place
>
> std::string tmp = p.get<std::string>("name");
>
> An error happens
> RuntimeError: Error! An attempt was made to access parameter
> "name" of
> type "string"
> in the parameter (sub)list "ANONYMOUS"
> using the incorrect type "string"!
>
> Any idea how to get around this error?
>
> BR
>
>
>
> On 03/18/13 15:36, Heroux, Mike wrote:
> > None of the second arguments should have quotes around them.
> You should
> > use:
> >
> > solver_parameters.set("AZ_solver",AZ_bicgstab)
> > solver_parameters.set("AZ_kspace",100)
> > solver_parameters.set("AZ_output",32)
> > solver_parameters.set("AZ_precond",AZ_none)
> >
> > Does this work?
> >
> >
> > On 3/15/13 7:09 AM, "Hoang Giang Bui" <hgbk2008 at gmail.com
> <mailto:hgbk2008 at gmail.com>> wrote:
> >
> >> Hi
> >>
> >> I recently encounter a strange error using
> Teuchos::ParameterList:
> >>
> >> setting the parameters and pass to aztec_solver:
> >>
> >> =====================
> >> solver_parameters.set("AZ_solver","AZ_bicgstab")
> >> solver_parameters.set("AZ_kspace",100)
> >> solver_parameters.set("AZ_output",32)
> >> solver_parameters.set("AZ_precond","AZ_none")
> >>
> >> aztec_solver.SetParameters(solver_parameters);
> >>
> >> =====================
> >>
> >> throws an error:
> >>
> >> =====================
> >> RuntimeError:
> >>
> /home/bui/sw/trilinos-public/packages/teuchos/core/src/Teuchos_any.hpp:287
> >> :
> >>
> >> Throw number = 1
> >>
> >> Throw test that evaluated to true: !dyn_cast_content
> >>
> >> any_cast<int>(operand): Error, cast to type
> any::holder<int> failed but
> >> should not have and the actual underlying type is
> >> 'Teuchos::any::holder<int>! The problem might be related to
> >> incompatible RTTI systems in static and shared libraries!
> >>
> >> =====================
> >>
> >> When I changed to this
> >>
> >> solver_parameters.set("AZ_solver","AZ_bicgstab")
> >> solver_parameters.set("AZ_kspace","100")
> >> solver_parameters.set("AZ_output","32")
> >> solver_parameters.set("AZ_precond","AZ_none")
> >>
> >> The error is gone. But I don't know if the parameter list
> can detect the
> >> integer value as string value ?
> >>
> >> BR
> >> Bui
> >>
> >>
> >>
> >> _______________________________________________
> >> Trilinos-Users mailing list
> >> Trilinos-Users at software.sandia.gov
> <mailto:Trilinos-Users at software.sandia.gov>
> >> http://software.sandia.gov/mailman/listinfo/trilinos-users
> >>
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> <mailto:Trilinos-Users at software.sandia.gov>
> http://software.sandia.gov/mailman/listinfo/trilinos-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20130409/7c6ea131/attachment.html
More information about the Trilinos-Users
mailing list