[Trilinos-Users] precision double in for Teuchos XMLObject ostream

George Pau gpau at lbl.gov
Sat Mar 3 17:12:18 MST 2012


Hi,

I have a code that read in an XML file, save it as a ParameterList and then write it to a new XML file again.  What I notice is that the precision of parameter of type double drops in the new XML file.  For example, even though I specified 7 decimal points in the original XML file, my new XML file shows the same value to only 5 decimal points.  Is there anyway that I can maintain the precision in my new XML file?  

My code for writing out the xml file is as follows:

void writeOutputFile (const std::string filename
         	       const Teuchos::ParameterList my_list)
{
  std::ofstream out_file(filename.c_str(),std::ios::out);
  out_file.setf(std::ios::scientific); 
  out_file.precision(12);
  
  Teuchos::XMLParameterListWriter write_xml;
  Teuchos::XMLObject obj_xml = write_xml.toXML(my_list);
  out_file << obj_xml;

  out_file.close();
}

George





More information about the Trilinos-Users mailing list