From: RENARD P. <Phi...@un...> - 2006-08-25 21:46:59
|
Bonjour ! I am trying to parse a geostat algo parameter file in order to analyze it, check its coherence with respect to some external information and simply run the simulation without modifying the parameters in a first step. I have not succeeded in doing so yet and I would appreciate a little (? hopefully) help.=20 What I have in my little program wrote is the following. // Open the parameter file std::ifstream paramfile( simul_parameter_file_name.c_str() ) ; if ( !paramfile ) { errors->report( "Simul_Parameter_File", "The simulation parameter file could not be open" ); return false; } // Read the parameter file and store it in a string std::string simul_parameter_string=3D""; char c; while (!paramfile.eof()) { c =3D paramfile.get(); simul_parameter_string+=3Dc; } cerr << simul_parameter_string; --> The part above is working. The string contains the equivalent of the file. <--- // Then this is something that Ting gave me: std::string parser =3D "/GeostatParamUtils/XML"; SmartPtr<Named_interface> ni_handler =3D Root::instance()->new_interface( "Parameters_handler://" + simul_parameter_string,=20 parser + "/" ); --> The part above seems to work the pointer contains some information if( ni_handler.raw_ptr() =3D=3D 0 ) { appli_warning( "Manager " << parser=20 << " can't create interface for Parameters_handler" ); return false; } SmartPtr<Parameters_handler> _handler =3D SmartPtr<Parameters_handler>(=20 dynamic_cast<Parameters_handler*>( ni_handler.raw_ptr() ) );=20 --> At that point, there is a problem. _handler is initialized correctly, but there is a flag that indicates that _is_ready is false. When I try to read information from the _handler (see below) it doesn't return it. =09 // Retrieve the simulation algorithm name with the parameter handler std::string algo=3D_handler->value( "algorithm.name" ); launch_simul.assign( algo+"::/GeostatParamUtils/XML::"+simul_parameter_string ); --> And of course, when I try to run the simulation sgems crashes. proj->execute( "RunGeostatAlgorithm", launch_simul ); Any suggestion to solve the problem ? Furthermore, I also need to modify in a second step the parameters before running the simulations. I need that to condition each simulation with a different synthetic data set. I planned to do it by substituting some strings in the launch_simul string. But, I wonder if there should not be a standard method to do that ? I discussed about that this morning with Ting. He has the same type of problem to solve for history matching. Ting wrote for his purpose an access function that modifies the value of an entity through a parameter handle. I wonder if this should not be made available to everybody ?=20 Thanks ! Cheers, Philippe |