testXMLGFPreprocessor.C 1.9 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15 16 17
// testXMLGFPreprocessor.C
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
18
// $Id: testXMLGFPreprocessor.C,v 1.4 2008-09-08 15:56:20 fgygi Exp $
Francois Gygi committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42


#include <iostream>
#include <cassert>
#include <fstream>
#include <string>
using namespace std;

#include "Context.h"
#include "Matrix.h"
#include "XMLGFPreprocessor.h"

int main(int argc, char** argv)
{
#if USE_MPI
  MPI_Init(&argc,&argv);
#endif
  // extra scope to ensure that BlacsContext objects get destructed before
  // the MPI_Finalize call
  {
    assert(argc==4);
    const int nr = atoi(argv[1]);
    const int nc = atoi(argv[2]);
    const char* const filename = argv[3];
43

44
    Context ctxt(nr,nc); // context on which gfdata is defined
Francois Gygi committed
45 46
    DoubleMatrix gfdata(ctxt);
    string xmlcontent;
47

Francois Gygi committed
48 49 50
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int namelen;
    PMPI_Get_processor_name(processor_name,&namelen);
51
    cout << " Process " << gfdata.context().mype()
Francois Gygi committed
52 53 54
         << " on " << processor_name << endl;

    XMLGFPreprocessor xmlgfp;
55 56
    bool serial = true;
    xmlgfp.process(filename,gfdata,xmlcontent,serial);
57

Francois Gygi committed
58 59 60 61 62
#if 0
    // write all gfdata on file
    ofstream gf_file("gf.dat");
    gf_file << gfdata;
#endif
63

Francois Gygi committed
64 65 66 67 68 69 70 71 72 73 74
    if ( ctxt.onpe0() )
    {
      ofstream xmlfile("xml.dat");
      xmlfile << xmlcontent;
    }
  }
#if USE_MPI
  MPI_Finalize();
#endif
  return 0;
}