tools/convertPartition.cpp

Go to the documentation of this file.
00001 //*****************************************************************************//
00002 //                                                                             //
00003 //   Copyright (c) 2005                                                        //
00004 //      INRIA-Futurs                                                           //
00005 //*****************************************************************************//
00006 //                                                                             //
00007 //               *** NOTICE OF PROPRIETARY INFORMATION ***                     //
00008 //                                                                             //
00009 // The information contained in this file is considered proprietary and the    //
00010 // exclusive property of  INRIA. This information may not be disclosed,        //
00011 // duplicated or used, in whole or in part, for  any purpose  whatsoever       //
00012 // without express written authorization from INRIA                            //
00013 //                                                                             //
00014 //*****************************************************************************//
00015 //
00016 //  convertPartition: ../../include/QCAtoms.hpp:113: void QCAtoms::allocateAtoms(int): Assertion `atoms == __null' failed.
00017 //
00018 #include <string>
00019 #include <iostream>
00020 //
00021 #include "QCCommon.hpp"
00022 #include "QCReader.hpp"
00023 #include "QCManager.hpp"
00024 #include "QCFiles.hpp"
00025 //
00026 #include "QCPm3.hpp"
00027 #include "QCPm3Param.hpp"
00028 #include "QCMDSystem.hpp"
00029 #include "QCSystem.hpp"
00030 #include "QCDCAlgo.hpp"
00031 #include "QCKimikaPartitioner.hpp"
00032 
00033 #if defined (QC_TRACE_IN_FILE)  
00034 #include "QCTrace.hpp"
00035 #endif
00036 
00037 
00038 void help()
00039 {
00040   std::cout <<std::endl 
00041             <<"convertPartitionFormat -qci atomFileName -part partitionFileName -f (-old or new) -out filename" << std::endl
00042             <<std::endl; 
00043   exit(EXIT_FAILURE) ;
00044 }
00045 void usage()
00046 {
00047   std::cout << "Wrong number of arguments " << std::endl ;
00048   help();
00049   exit(EXIT_FAILURE) ;
00050 }
00051 
00052 int main (int argc, char **argv) 
00053 {
00054   
00055   std::string helpS("--help");
00056   //
00057   for( int i = 0 ; i < argc ; ++i){
00058     //    std::cout << i<<"  "<<argv[i] <<"    " << argc  <<std::endl;
00059     //    if (argv[i] == helpS )
00060     if (argv[i] == "--help\0" )
00061       { std::cout << "help call "<<std::endl;help();}
00062   }
00063 
00064   if(argc != 9){ usage() ; }
00065   std::ifstream dataFile;
00066   std::ofstream outFile;
00067   std::string atomsFileName, partFileName, outFileName, temp, format;
00068   int argATOMS= 0, argPartIN=0, argOUT=0, argF=0;
00069 
00070   for ( int a = 1 ; a < argc ; a += 2){
00071     std::string tmp(argv[a]) ;
00072     if (tmp == "-qci"){
00073       argATOMS = a+1 ;
00074       atomsFileName.assign(argv[a+1]);
00075     }
00076     else if (tmp == "-part"){
00077       argPartIN = a+1 ;
00078       partFileName.assign(argv[a+1]);
00079     }
00080     else if (tmp == "-out"){
00081       argOUT  = a+1 ;
00082       outFileName.assign(argv[a+1]);
00083     }
00084     else if ( tmp == "-f" || tmp == "-format"){
00085       argF = a+1 ;
00086       format.assign(argv[a+1]);
00087       if( !(format == "new" || format == "old"| format == "vtk") ){
00088         std::cerr << " error format option must be new or old" <<std::endl ;
00089         return EXIT_FAILURE ;
00090       }
00091     }
00092   }
00093   int iformat = -1;
00094   if(format == "new" )
00095     { iformat = 2 ;}
00096   else  if(format == "old" )
00097     { iformat = 1 ;}
00098   else  if(format == "vtk" )
00099     { iformat = 3 ;}
00100   //
00101   QCReader      reader;
00102   QCFiles       files;
00103   QCGeneralData data;
00104   //
00105   QCManager<QCPm3T<QCPm3Param>, QCMDSystem<QCDCAlgo> > manager;
00106   //
00107   //
00108   std::string parameterFile("Pm3Param") ;
00109   //
00110   files.parameterFile() = parameterFile ;
00111   files.atomsFile()     = atomsFileName ;
00112   files.partitionFile() = partFileName ;
00113   files.resultFile()    = outFileName ;
00114   //
00115   QCMDSystem<QCDCAlgo>  & mdSystem = manager.getSystem() ;
00116 
00117   QCKimikaPartitioner<QCMDSystem<QCDCAlgo> > partitioner ;
00118   data.setReadPartitionFileON() ;
00119   data.isDCComputation()         = true ;
00120   data.setComputationType("Tools");
00121   //
00122   //
00123   QC_TRACE("MAIN manager.init ");
00124   manager.initTools(files, data, ".");
00125   //
00126   cout <<   ">>> FILES <<<\n"        << manager.getFiles()       << endl
00127        <<   ">>> GENERAL DATA <<<\n" << manager.getGeneralData() << endl;
00128 
00129 
00130   std::cout << "Read partition file" <<std::endl;
00131   
00132   manager.getPartitioner() = &partitioner ;
00133   partitioner.readFromFile( mdSystem, const_cast<QCGeneralData&>(manager.getGeneralData()),
00134                             manager.getFiles(),  ".");
00135   manager.getPartitioner() = NULL ; 
00136   //
00137   //  Save parttion file in different formats
00138   //
00139   outFile.open(outFileName.c_str());
00140   //
00141   switch (iformat) {
00142   case 1:
00143     std::cout << " Write partitition in version 1 format." <<std::endl;
00144     partitioner.writeInFileV1(outFile,mdSystem);        
00145   break;
00146   case 2:
00147     std::cout << " Write partitition in version 2 format." <<std::endl;
00148     partitioner.writeInFileV2(outFile,mdSystem);        
00149     break;
00150   case 3:
00151     std::cout << " Write partitition in VTK format." <<std::endl;
00152     partitioner.writeInFileVTK(outFile,mdSystem);
00153     break;
00154   }
00155   outFile.close();
00156   //
00157   return QCPP_SUCCES;
00158 }

Generated on Sat Jan 28 21:07:24 2006 for QC++ by  doxygen 1.4.4