qprop_io.cc

Go to the documentation of this file.
00001 // $Id: qprop_io.cc,v 3.21 2009/01/29 16:57:28 caubin Exp $
00002 /*! \file
00003  * \brief Routines associated with Chroma propagator IO
00004  */
00005 
00006 #include "chromabase.h"
00007 #include "io/param_io.h"
00008 #include "io/qprop_io.h"
00009 
00010 #include "meas/smear/simple_quark_displacement.h"
00011 #include "meas/smear/ape_link_smearing.h"
00012 
00013 namespace Chroma 
00014 {
00015 
00016   // Given a fermion action in string form, return the Mass
00017   Real getMass(const GroupXML_t& fermact)
00018   {
00019     //
00020     // Initialize fermion action
00021     //
00022     std::istringstream  xml_s(fermact.xml);
00023     XMLReader  fermacttop(xml_s);
00024     XMLReader  top(fermacttop, fermact.path);
00025 
00026     Real Mass;
00027 
00028     try
00029     {
00030       if (top.count("Mass") != 0) 
00031       {
00032         read(top, "Mass", Mass);
00033       }
00034       else if (top.count("Kappa") != 0)
00035       {
00036         Real Kappa;
00037         read(top, "Kappa", Kappa);
00038         Mass = kappaToMass(Kappa);    // Convert Kappa to Mass
00039       }
00040       else if (top.count("m_q") != 0) 
00041       {
00042         read(top, "m_q", Mass);
00043       }
00044       else
00045       {
00046         QDPIO::cerr << "Neither Mass nor Kappa found" << endl;
00047         throw std::string("Neither Mass nor Kappa found");
00048       }
00049     }
00050     catch (const std::string& e) 
00051     {
00052       QDPIO::cerr << "Error reading fermact: " << e << endl;
00053       throw e;
00054     }
00055 
00056     return Mass;
00057   }
00058 
00059 
00060   // Given a fermion action in string form, return the boundary
00061   /* HACK - THIS DEFINITELY NEEDS IMPROVEMENT */
00062   multi1d<int> getFermActBoundary(const GroupXML_t& fermact)
00063   {
00064     //
00065     // Initialize fermion action
00066     //
00067     std::istringstream  xml_s(fermact.xml);
00068     XMLReader  fermacttop(xml_s);
00069     XMLReader  top(fermacttop, fermact.path);
00070 
00071     multi1d<int> boundary;
00072 
00073     // Throw exception if boundary not found
00074 //    try
00075     {
00076       if (top.count("FermState/FermionBC/boundary") != 0)
00077       {
00078         read(top, "FermState/FermionBC/boundary", boundary);
00079       }
00080       else if (top.count("FermionBC/boundary") != 0)
00081       {
00082         read(top, "FermionBC/boundary", boundary);
00083       }
00084       else if (top.count("boundary") != 0)
00085       {
00086         read(top, "boundary", boundary);
00087       }
00088       else
00089       {
00090         std::ostringstream os;
00091         os << __func__ << ": Warning: neither FermionBC group nor boundary found - throwing exception. If this is not caught the code will exit" << endl;
00092         QDPIO::cerr << os.str();
00093         throw os.str();
00094       }
00095     }
00096 //    catch (const std::string& e) 
00097 //    {
00098 //      QDPIO::cerr << "Error reading fermact: " << e << endl;
00099 //      throw e;
00100 //    }
00101 
00102     if (boundary.size() != Nd)
00103     {
00104       QDPIO::cerr << __func__ << ": boundary is not the expected length = Nd" << endl;
00105       QDP_abort(1);
00106     }
00107 
00108     return boundary;
00109   }
00110 
00111 
00112 
00113   // Initialize header with default values
00114   PropSourceConst_t::PropSourceConst_t()
00115   {
00116     j_decay   = -1;
00117     t_source  = -1;
00118   }
00119 
00120   // Given a prop source xml in string form, return the t_srce
00121   multi1d<int> PropSourceConst_t::getTSrce() const
00122   {
00123     //
00124     // Initialize source xml
00125     //
00126     std::istringstream  xml_s(source.xml);
00127     XMLReader  sourcetop(xml_s);
00128 
00129     multi1d<int> t_srce;
00130     multi1d<int> t_source;
00131 
00132     try
00133     {
00134       XMLReader  top(sourcetop, source.path);
00135 
00136       read(top, "t_srce", t_srce);
00137     }
00138     catch (const std::string& e) 
00139     {
00140       try
00141         {
00142           XMLReader  top(sourcetop, source.path);
00143 
00144           read(top, "t_source", t_source);
00145           t_srce.resize(Nd);
00146           t_srce[Nd-1] = t_source[0];
00147           for(int i=0;i<Nd-1;i++)
00148             t_srce[i] = 0;
00149         }
00150       catch (const std::string& e)
00151         {
00152           QDPIO::cerr << "Error reading source: " << e << endl;
00153           throw e;
00154         }
00155     }
00156 
00157     return t_srce;
00158   }
00159 
00160   // Given a prop source xml in string form, return the Momentum
00161   // works with momentum sources
00162   multi1d<int> PropSourceConst_t::getMom() const
00163   {
00164     //
00165     // Initialize source xml
00166     //
00167     std::istringstream  xml_s(source.xml);
00168     XMLReader  sourcetop(xml_s);
00169 
00170     multi1d<int> t_srce;
00171 
00172     try
00173     {
00174       XMLReader  top(sourcetop, source.path);
00175 
00176       read(top, "mom", t_srce);
00177     }
00178     catch (const std::string& e) 
00179     {
00180       QDPIO::cerr << "Error reading source: " << e << endl;
00181       throw e;
00182     }
00183 
00184     return t_srce;
00185   }
00186 
00187 
00188   // Initialize header with default values
00189   PropSourceSmear_t::PropSourceSmear_t()
00190   {
00191     j_decay   = -1;
00192   }
00193 
00194 
00195   // Initialize header with default values
00196   PropSinkSmear_t::PropSinkSmear_t()
00197   {
00198     j_decay = -1;
00199   }
00200 
00201 
00202   // Initialize header with default values
00203   SeqSource_t::SeqSource_t()
00204   {
00205     j_decay   = -1;
00206     t_sink    = -1;
00207     sink_mom.resize(Nd-1);
00208     sink_mom = 0;
00209   }
00210 
00211 
00212   // Initialize header with default values
00213   ChromaProp_t::ChromaProp_t()
00214   {
00215     obsvP       = true;
00216     // Create an document with an empty state info tag
00217   }
00218 
00219   // Initialize header with default values
00220   ChromaMultiProp_t::ChromaMultiProp_t()
00221   {
00222   }
00223 
00224 
00225   // Initialize header with default values
00226   QQQBarcomp_t::QQQBarcomp_t()
00227   {
00228     sparseP     = false;
00229     Dirac_basis = true;
00230     forward_props.resize(3);
00231   }
00232 
00233 
00234   // Initialize header with default values
00235   QQbarMescomp_t::QQbarMescomp_t()
00236   {
00237     Dirac_basis = true;
00238     forward_props.resize(3);
00239   }
00240 
00241 
00242   // Anonymous namespace
00243   namespace 
00244   {
00245     //! V5 Source header read 
00246     /*! This routine is SOLELY for backwards compatibility. It should go. */
00247     void readV5(XMLReader& xml, const string& path, PropSourceConst_t& header)
00248     {
00249       XMLReader paramtop(xml, path);
00250 
00251       int version;
00252       read(paramtop, "version", version);
00253 
00254       read(paramtop, "source_type", header.source.id);
00255 
00256       std::string wave_state;
00257       read(paramtop, "wave_state", wave_state);
00258       if (wave_state != "S_WAVE")
00259       {
00260         throw std::string("version 5 only supports S_WAVE");
00261       }
00262 
00263       multi1d<int> t_srce;
00264       read(paramtop, "j_decay",  header.j_decay);
00265       read(paramtop, "t_source", t_srce);
00266 
00267       if (header.source.id == "SHELL_SOURCE")
00268       {
00269         XMLReader shelltop(paramtop, "ShellSource");
00270 
00271         std::string wvf_kind;
00272         Real wvf_param;
00273         int  wvfIntPar;
00274         {
00275           XMLReader smeartop(shelltop, "SourceSmearingParam");
00276             
00277           read(smeartop, "wvf_kind", wvf_kind);
00278           read(smeartop, "wvf_param", wvf_param);
00279           read(smeartop, "wvfIntPar", wvfIntPar);
00280         }
00281 
00282         int laplace_power;
00283         read(shelltop, "laplace_power", laplace_power);
00284         if (laplace_power != 0)
00285           throw std::string("only laplace_power=0 supported");
00286 
00287         Real link_smear_fact;
00288         int link_smear_num;
00289         read(shelltop, "link_smear_fact", link_smear_fact);
00290         read(shelltop, "link_smear_num", link_smear_num);
00291 
00292         int disp_length;
00293         int disp_dir;
00294         read(shelltop, "disp_length", disp_length);
00295         read(shelltop, "disp_dir", disp_dir);
00296 
00297         XMLReader xml_readback;
00298         {
00299           XMLBufferWriter xml_tmp;
00300           push(xml_tmp, "Param");
00301           write(xml_tmp, "version", 6);
00302           push(xml_tmp, "Source");
00303           write(xml_tmp, "version", 2);
00304           write(xml_tmp, "SourceType", header.source.id);
00305 
00306           {
00307             push(xml_tmp, "SmearingParam");
00308             write(xml_tmp, "wvf_kind", wvf_kind);
00309             write(xml_tmp, "wvf_param", wvf_param);
00310             write(xml_tmp, "wvfIntPar", wvfIntPar);
00311             write(xml_tmp, "no_smear_dir", header.j_decay);
00312             pop(xml_tmp);
00313           }
00314 
00315           {
00316             push(xml_tmp, "Displacement");
00317             write(xml_tmp, "DisplacementType", SimpleQuarkDisplacementEnv::getName());
00318 
00319             write(xml_tmp, "disp_length", disp_length);
00320             write(xml_tmp, "disp_dir",  disp_dir);
00321 
00322             pop(xml_tmp);  // Displacement
00323           }
00324 
00325           {
00326             push(xml_tmp, "LinkSmearing");
00327             write(xml_tmp, "LinkSmearingType", APELinkSmearingEnv::getName());
00328             write(xml_tmp, "link_smear_num", link_smear_num);
00329             write(xml_tmp, "link_smear_fact", link_smear_fact);
00330             write(xml_tmp, "no_smear_dir", header.j_decay);
00331             pop(xml_tmp);
00332           }
00333 
00334           write(xml_tmp, "t_srce",  t_srce);
00335           write(xml_tmp, "j_decay",  header.j_decay);
00336 
00337           pop(xml_tmp);  // Source
00338           pop(xml_tmp);  // Param
00339 
00340           QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00341 
00342           xml_readback.open(xml_tmp);
00343         }
00344 
00345         // Recurse back in to re-read
00346         read(xml_readback, "/Param", header);
00347       }
00348       else if (header.source.id == "POINT_SOURCE")
00349       {
00350         XMLReader xml_readback;
00351         {
00352           XMLBufferWriter xml_tmp;
00353           push(xml_tmp, "Param");
00354           write(xml_tmp, "version", 6);
00355           push(xml_tmp, "Source");
00356           write(xml_tmp, "version", 1);
00357           write(xml_tmp, "SourceType", header.source.id);
00358 
00359           write(xml_tmp, "t_srce",  t_srce);
00360           write(xml_tmp, "j_decay",  header.j_decay);
00361 
00362           pop(xml_tmp);  // Source
00363           pop(xml_tmp);  // Param
00364 
00365           QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00366 
00367           xml_readback.open(xml_tmp);
00368         }
00369 
00370         // Recurse back in to re-read
00371         read(xml_readback, "/Param", header);
00372       }
00373       else if (header.source.id == "WALL_SOURCE")
00374       {
00375         XMLReader xml_readback;
00376         {
00377           XMLBufferWriter xml_tmp;
00378           push(xml_tmp, "Param");
00379           write(xml_tmp, "version", 6);
00380           push(xml_tmp, "Source");
00381           write(xml_tmp, "version", 1);
00382           write(xml_tmp, "SourceType", header.source.id);
00383 
00384           write(xml_tmp, "t_source",  t_srce[header.j_decay]);
00385           write(xml_tmp, "j_decay",  header.j_decay);
00386 
00387           pop(xml_tmp);  // Source
00388           pop(xml_tmp);  // Param
00389 
00390           QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00391 
00392           xml_readback.open(xml_tmp);
00393         }
00394 
00395         // Recurse back in to re-read
00396         read(xml_readback, "/Param", header);
00397       }
00398       else if (header.source.id == "RAND_Z2_WALL_SOURCE")
00399       {
00400         XMLReader xml_readback;
00401         {
00402           XMLBufferWriter xml_tmp;
00403           push(xml_tmp, "Param");
00404           write(xml_tmp, "version", 6);
00405           push(xml_tmp, "Source");
00406           write(xml_tmp, "version", 1);
00407           write(xml_tmp, "SourceType", header.source.id);
00408 
00409           write(xml_tmp, "t_source",  t_srce[header.j_decay]);
00410           write(xml_tmp, "j_decay",  header.j_decay);
00411 
00412           pop(xml_tmp);  // Source
00413           pop(xml_tmp);  // Param
00414 
00415           QDPIO::cout << "source_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00416 
00417           xml_readback.open(xml_tmp);
00418         }
00419 
00420         // Recurse back in to re-read
00421         read(xml_readback, "/Param", header);
00422       }
00423       else
00424       {
00425         std::ostringstream  os;
00426         os << "Unsupported source type= " << header.source.id 
00427            << "  in file= " << __FILE__ 
00428            << "  at line= " << __LINE__
00429            << endl;
00430         throw os.str();
00431       }
00432     }
00433 
00434 
00435     //! V4 Sink header read 
00436     /*! This routine is SOLELY for backwards compatibility. It should go. */
00437     void readV4(XMLReader& xml, const string& path, PropSinkSmear_t& header)
00438     {
00439       XMLReader paramtop(xml, path);
00440 
00441       int version;
00442       read(paramtop, "version", version);
00443 
00444       read(paramtop, "sink_type", header.sink.id);
00445 
00446       std::string wave_state;
00447       read(paramtop, "wave_state", wave_state);
00448       if (wave_state != "S_WAVE")
00449       {
00450         throw std::string("version 4 only supports S_WAVE");
00451       }
00452 
00453       read(paramtop, "j_decay", header.j_decay);
00454 
00455       if (header.sink.id == "SHELL_SINK")
00456       {
00457         XMLReader shelltop(paramtop, "ShellSink");
00458 
00459         std::string wvf_kind;
00460         Real wvf_param;
00461         int  wvfIntPar;
00462         {
00463           XMLReader smeartop(shelltop, "SinkSmearingParam");
00464             
00465           read(smeartop, "wvf_kind", wvf_kind);
00466           read(smeartop, "wvf_param", wvf_param);
00467           read(smeartop, "wvfIntPar", wvfIntPar);
00468         }
00469 
00470         int laplace_power;
00471         read(shelltop, "laplace_power", laplace_power);
00472         if (laplace_power != 0)
00473           throw std::string("only laplace_power=0 supported");
00474 
00475         Real link_smear_fact;
00476         int link_smear_num;
00477         read(shelltop, "link_smear_fact", link_smear_fact);
00478         read(shelltop, "link_smear_num", link_smear_num);
00479 
00480         int disp_length;
00481         int disp_dir;
00482         read(shelltop, "disp_length", disp_length);
00483         read(shelltop, "disp_dir", disp_dir);
00484 
00485         XMLReader xml_readback;
00486         {
00487           XMLBufferWriter xml_tmp;
00488           push(xml_tmp, "Param");
00489           write(xml_tmp, "version", 6);
00490           push(xml_tmp, "Sink");
00491           write(xml_tmp, "version", 2);
00492           write(xml_tmp, "SinkType", header.sink.id);
00493 
00494           {
00495             push(xml_tmp, "SmearingParam");
00496             write(xml_tmp, "wvf_kind", wvf_kind);
00497             write(xml_tmp, "wvf_param", wvf_param);
00498             write(xml_tmp, "wvfIntPar", wvfIntPar);
00499             write(xml_tmp, "no_smear_dir", header.j_decay);
00500             pop(xml_tmp);
00501           }
00502 
00503           {
00504             push(xml_tmp, "Displacement");
00505             write(xml_tmp, "DisplacementType", SimpleQuarkDisplacementEnv::getName());
00506 
00507             write(xml_tmp, "disp_length", disp_length);
00508             write(xml_tmp, "disp_dir",  disp_dir);
00509 
00510             pop(xml_tmp);  // Displacement
00511           }
00512 
00513           {
00514             push(xml_tmp, "LinkSmearing");
00515             write(xml_tmp, "LinkSmearingType", APELinkSmearingEnv::getName());
00516             write(xml_tmp, "link_smear_num", link_smear_num);
00517             write(xml_tmp, "link_smear_fact", link_smear_fact);
00518             write(xml_tmp, "no_smear_dir", header.j_decay);
00519             pop(xml_tmp);
00520           }
00521 
00522           pop(xml_tmp);  // Sink
00523           pop(xml_tmp);  // Param
00524 
00525           QDPIO::cout << "sink_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00526 
00527           xml_readback.open(xml_tmp);
00528         }
00529 
00530         // Recurse back in to re-read
00531         read(xml_readback, "/Param", header);
00532       }
00533       else if (header.sink.id == "POINT_SINK")
00534       {
00535         XMLReader xml_readback;
00536         {
00537           XMLBufferWriter xml_tmp;
00538           push(xml_tmp, "Param");
00539           write(xml_tmp, "version", 6);
00540           push(xml_tmp, "Sink");
00541           write(xml_tmp, "version", 1);
00542           write(xml_tmp, "SinkType", header.sink.id);
00543 
00544           write(xml_tmp, "j_decay",  header.j_decay);
00545 
00546           pop(xml_tmp);  // Sink
00547           pop(xml_tmp);  // Param
00548 
00549           QDPIO::cout << "sink_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00550 
00551           xml_readback.open(xml_tmp);
00552         }
00553 
00554         // Recurse back in to re-read
00555         read(xml_readback, "/Param", header);
00556       }
00557       else if (header.sink.id == "WALL_SINK")
00558       {
00559         XMLReader xml_readback;
00560         {
00561           XMLBufferWriter xml_tmp;
00562           push(xml_tmp, "Param");
00563           write(xml_tmp, "version", 6);
00564           push(xml_tmp, "Sink");
00565           write(xml_tmp, "version", 1);
00566           write(xml_tmp, "SinkType", header.sink.id);
00567 
00568           pop(xml_tmp);  // Sink
00569           pop(xml_tmp);  // Param
00570 
00571           QDPIO::cout << "sink_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00572 
00573           xml_readback.open(xml_tmp);
00574         }
00575 
00576         // Recurse back in to re-read
00577         read(xml_readback, "/Param", header);
00578       }
00579       else
00580       {
00581         std::ostringstream  os;
00582         os << "Unsupported sink type= " << header.sink.id 
00583            << "  in file= " << __FILE__ 
00584            << "  at line= " << __LINE__
00585            << endl;
00586         throw os.str();
00587       }
00588     }
00589   }
00590 
00591 
00592 
00593   // Source header read
00594   void read(XMLReader& xml, const string& path, PropSourceConst_t& header)
00595   {
00596     XMLReader paramtop(xml, path);
00597 
00598     int version;
00599     read(paramtop, "version", version);
00600 
00601     try
00602     {
00603       switch (version) 
00604       {
00605       case 5:
00606         readV5(xml, path, header);
00607         break;
00608 
00609       case 6:
00610       {
00611         header.source = readXMLGroup(paramtop, "Source", "SourceType");
00612 
00613         XMLReader xml_tmp(paramtop, "Source");
00614         read(xml_tmp, "j_decay", header.j_decay);
00615         if (xml_tmp.count("t_source") != 0)
00616         {
00617           read(xml_tmp, "t_source", header.t_source);
00618         }
00619         else if (xml_tmp.count("t_srce") != 0)
00620         {
00621           multi1d<int> t_srce;
00622           read(xml_tmp, "t_srce", t_srce);
00623           if (t_srce.size() != Nd)
00624           {
00625             throw string("t_srce not expected size");
00626           }
00627           header.t_source = t_srce[header.j_decay];
00628         }
00629         else
00630         {
00631           throw string("neither t_source nor t_srce found");
00632         }
00633       }
00634       break;
00635 
00636       default:
00637         /**************************************************************************/
00638         QDPIO::cerr << "PropSourceConst parameter version " << version 
00639                     << " unsupported." << endl;
00640         QDP_abort(1);
00641       }
00642     }
00643     catch (const std::string& e) 
00644     {
00645       QDPIO::cerr << "PropSourceConst: Error reading source: " << e << endl;
00646       QDP_abort(1);
00647     }
00648   }
00649 
00650 
00651   // Source header read
00652   void read(XMLReader& xml, const string& path, PropSourceSmear_t& header)
00653   {
00654     XMLReader paramtop(xml, path);
00655 
00656     int version;
00657     read(paramtop, "version", version);
00658 
00659     switch (version) 
00660     {
00661     case 6:
00662     {
00663       header.source = readXMLGroup(paramtop, "Source", "SourceType");
00664 
00665       XMLReader xml_tmp(paramtop, "Source");
00666       read(xml_tmp, "j_decay", header.j_decay);
00667     }
00668     break;
00669 
00670     default:
00671       /**************************************************************************/
00672       QDPIO::cerr << "PropSourceSmear parameter version " << version 
00673                   << " unsupported." << endl;
00674       QDP_abort(1);
00675     }
00676   }
00677 
00678 
00679   // Source header read
00680   void read(XMLReader& xml, const string& path, PropSinkSmear_t& header)
00681   {
00682     XMLReader paramtop(xml, path);
00683 
00684     int version;
00685     read(paramtop, "version", version);
00686 
00687     try
00688     {
00689       switch (version) 
00690       {
00691       case 4:
00692         readV4(xml, path, header);
00693         break;
00694 
00695       case 5:
00696       {
00697         header.sink = readXMLGroup(paramtop, "Sink", "SinkType");
00698 
00699         XMLReader xml_tmp(paramtop, "Sink");
00700         read(xml_tmp, "j_decay", header.j_decay);
00701       }
00702       break;
00703 
00704       default:
00705         /**************************************************************************/
00706         QDPIO::cerr << "PropSinkSmear parameter version " << version 
00707                     << " unsupported." << endl;
00708         QDP_abort(1);
00709       }
00710     }
00711     catch (const std::string& e) 
00712     {
00713       QDPIO::cerr << "PropSinkSmear: Error reading sink: " << e << endl;
00714       QDP_abort(1);
00715     }
00716 
00717   }
00718 
00719 
00720   //! SeqSource header reader
00721   void read(XMLReader& xml, const string& path, SeqSource_t& param)
00722   {
00723     XMLReader paramtop(xml, path);
00724 
00725     int version;
00726     read(paramtop, "version", version);
00727 
00728     switch (version) 
00729     {
00730     case 1:
00731     {
00732       XMLReader xml_readback;
00733       {
00734         XMLBufferWriter xml_tmp;
00735         push(xml_tmp, "Param");
00736         write(xml_tmp, "version", 2);
00737         push(xml_tmp, "SeqSource");
00738         write(xml_tmp, "version", 1);
00739         std::string seq_src;
00740         read(paramtop, "seq_src", seq_src);
00741         write(xml_tmp, "SeqSourceType", seq_src);
00742 
00743         read(paramtop, "sink_mom", param.sink_mom);
00744         write(xml_tmp, "sink_mom",  param.sink_mom);
00745 
00746         read(paramtop, "t_sink", param.t_sink);
00747         write(xml_tmp, "t_sink",  param.t_sink);
00748 
00749         write(xml_tmp, "j_decay",  Nd-1);
00750 
00751         pop(xml_tmp);  // Source
00752         pop(xml_tmp);  // Param
00753 
00754         QDPIO::cout << "seqsrc_xml = XX" << xml_tmp.printCurrentContext() << "XX" << endl;
00755 
00756         xml_readback.open(xml_tmp);
00757       }
00758 
00759       // Recurse back in to re-read
00760       read(xml_readback, "/Param", param);
00761     }
00762     break;
00763 
00764     case 2:
00765     {
00766       param.seqsrc = readXMLGroup(paramtop, "SeqSource", "SeqSourceType");
00767 
00768       XMLReader xml_tmp(paramtop, "SeqSource");
00769       read(xml_tmp, "t_sink", param.t_sink);
00770       read(xml_tmp, "sink_mom", param.sink_mom);
00771       read(xml_tmp, "j_decay", param.j_decay);
00772     }
00773     break;
00774 
00775     default:
00776       QDPIO::cerr << "SeqSource parameter version " << version 
00777                   << " unsupported." << endl;
00778       QDP_abort(1);
00779     }
00780 
00781   }
00782 
00783 
00784   // Forward propagator header read
00785   void read(XMLReader& xml, const string& path, ChromaProp_t& param)
00786   {
00787     XMLReader paramtop(xml, path);
00788 
00789     int version;
00790     read(paramtop, "version", version);
00791 
00792     multi1d<int> boundary;
00793 
00794     param.quarkSpinType = QUARK_SPIN_TYPE_FULL;
00795     param.obsvP = true;
00796 
00797     switch (version) 
00798     {
00799       /**************************************************************************/
00800     case 4:
00801     {
00802       // In V4 the fermion action specific stuff is within the <Param> tag and not
00803       // in a <FermionAction> tag beneath <Param>
00804       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00805       read(paramtop, "boundary", boundary);
00806 
00807       XMLBufferWriter xml_out;
00808       push(xml_out,"FermionAction");
00809       xml_out << paramtop;
00810       pop(xml_out);
00811 
00812       XMLReader xml_inn(xml_out);
00813       param.fermact = readXMLGroup(xml_inn, "/FermionAction", "FermAct");
00814     }
00815     break;
00816 
00817     /**************************************************************************/
00818     case 5:
00819     {
00820       // In this modified version of v4, the fermion action specific stuff
00821       // goes into a <FermionAction> tag beneath <Param>
00822       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00823       read(paramtop, "boundary", boundary);
00824 
00825       XMLReader xml_tmp(paramtop, "FermionAction");
00826 
00827       XMLBufferWriter xml_out;
00828       push(xml_out,"FermionAction");
00829       xml_out << xml_tmp;
00830       write(xml_out, "boundary", boundary);
00831       pop(xml_out);
00832 
00833       XMLReader xml_inn(xml_out);
00834       param.fermact = readXMLGroup(xml_inn, "/FermionAction", "FermAct");
00835     }
00836     break;
00837 
00838     /**************************************************************************/
00839     case 6:
00840     {
00841       bool nonRelProp;
00842       read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
00843       if (nonRelProp)
00844         param.quarkSpinType = QUARK_SPIN_TYPE_UPPER;
00845 
00846       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00847       read(paramtop, "boundary", boundary);
00848 
00849       XMLReader xml_tmp(paramtop, "FermionAction");
00850 
00851       XMLBufferWriter xml_out;
00852       push(xml_out,"FermionAction");
00853       xml_out << xml_tmp;
00854       write(xml_out, "boundary", boundary);
00855       pop(xml_out);
00856 
00857       XMLReader xml_inn(xml_out);
00858       param.fermact = readXMLGroup(xml_inn, "/FermionAction", "FermAct");
00859     }
00860     break;
00861 
00862     /**************************************************************************/
00863     case 7:
00864     {
00865       param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
00866       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00867 
00868       bool nonRelProp;
00869       read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
00870       if (nonRelProp)
00871         param.quarkSpinType = QUARK_SPIN_TYPE_UPPER;
00872 
00873       if (paramtop.count("obsvP") != 0)
00874       {
00875         read(paramtop, "obsvP", param.obsvP);
00876       }
00877 
00878       if (paramtop.count("boundary") != 0)
00879       {
00880         QDPIO::cerr << "ChromaProp: paranoia check - found a misplaced boundary" << endl; 
00881         QDP_abort(1);
00882       }
00883     }
00884     break;
00885 
00886     case 8:
00887     {
00888       param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
00889 
00890       bool nonRelProp;
00891       read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
00892       if (nonRelProp)
00893         param.quarkSpinType = QUARK_SPIN_TYPE_UPPER;
00894 
00895       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00896       read(paramtop, "obsvP", param.obsvP);
00897 
00898       if (paramtop.count("boundary") != 0)
00899       {
00900         QDPIO::cerr << "ChromaProp: paranoia check - found a misplaced boundary" << endl; 
00901         QDP_abort(1);
00902       }
00903     }
00904     break;
00905 
00906     case 9:
00907     case 10:
00908     {
00909       // NOTE: now version 10 and 9 are identical. Version 10 use to read
00910       // numRetries, but that functionality has been removed and the
00911       // param is ignored.
00912       param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
00913 
00914       read(paramtop, "quarkSpinType", param.quarkSpinType); // which quark spins to compute
00915       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00916       read(paramtop, "obsvP", param.obsvP);
00917 
00918       if (paramtop.count("boundary") != 0)
00919       {
00920         QDPIO::cerr << "ChromaProp: paranoia check - found a misplaced boundary" << endl; 
00921         QDP_abort(1);
00922       }
00923     }
00924     break;
00925 
00926     default:
00927       /**************************************************************************/
00928       QDPIO::cerr << "ChromaProp parameter version " << version 
00929                   << " unsupported." << endl;
00930       QDP_abort(1);
00931     }
00932 
00933   }
00934 
00935 
00936   // Forward propagator header read
00937   void read(XMLReader& xml, const string& path, ChromaMultiProp_t& param)
00938   {
00939     XMLReader paramtop(xml, path);
00940 
00941     int version;
00942     read(paramtop, "version", version);
00943 
00944     param.quarkSpinType = QUARK_SPIN_TYPE_FULL;
00945     multi1d<int> boundary;
00946 
00947     switch (version) 
00948     {
00949       /**************************************************************************/
00950     case 5:  // Backward compatibility with non Multi ChromaProp_t
00951       /**************************************************************************/
00952     {
00953       read(paramtop, "MultiMasses", param.MultiMasses);
00954     
00955       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00956       read(paramtop, "boundary", boundary);
00957 
00958       XMLReader xml_tmp(paramtop, "FermionAction");
00959 
00960       XMLBufferWriter xml_out;
00961       push(xml_out,"FermionAction");
00962       xml_out << xml_tmp;
00963       write(xml_out, "boundary", boundary);
00964       pop(xml_out);
00965 
00966       XMLReader xml_inn(xml_out);
00967       param.fermact = readXMLGroup(xml_inn, "FermionAction", "FermAct");
00968     }
00969     break;
00970 
00971     /**************************************************************************/
00972     case 6:  // Backward compatibility with non Multi ChromaProp_t
00973       /**************************************************************************/
00974     {
00975       read(paramtop, "MultiMasses", param.MultiMasses);
00976 
00977       bool nonRelProp;
00978       read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
00979       if (nonRelProp)
00980         param.quarkSpinType = QUARK_SPIN_TYPE_UPPER;
00981 
00982       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
00983       read(paramtop, "boundary", boundary);
00984 
00985       XMLReader xml_tmp(paramtop, "FermionAction");
00986 
00987       XMLBufferWriter xml_out;
00988       push(xml_out,"FermionAction");
00989       xml_out << xml_tmp;
00990       write(xml_out, "boundary", boundary);
00991       pop(xml_out);
00992 
00993       XMLReader xml_inn(xml_out);
00994       param.fermact = readXMLGroup(xml_inn, "FermionAction", "FermAct");
00995     }
00996     break;
00997 
00998     /**************************************************************************/
00999     case 7:
01000       /**************************************************************************/
01001     {
01002       read(paramtop, "MultiMasses", param.MultiMasses);
01003 
01004       param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
01005       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
01006 
01007       bool nonRelProp;
01008       read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
01009       if (nonRelProp)
01010         param.quarkSpinType = QUARK_SPIN_TYPE_UPPER;
01011 
01012       if (paramtop.count("boundary") != 0)
01013       {
01014         QDPIO::cerr << "ChromaMultiProp: paranoia check - found a misplaced boundary" << endl; 
01015         QDP_abort(1);
01016       }
01017     }
01018     break;
01019 
01020     /* Compatibility with non MultiQprop */
01021     case 8:
01022     {
01023       read(paramtop, "MultiMasses", param.MultiMasses);
01024 
01025       param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
01026       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
01027 
01028       bool nonRelProp;
01029       read(paramtop, "nonRelProp", nonRelProp); // new - is this prop non-relativistic
01030       if (nonRelProp)
01031         param.quarkSpinType = QUARK_SPIN_TYPE_UPPER;
01032     }
01033     break;
01034 
01035 
01036     /* Compatibility with non MultiQprop */
01037     case 9:
01038     {
01039       read(paramtop, "MultiMasses", param.MultiMasses);
01040 
01041       param.fermact = readXMLGroup(paramtop, "FermionAction", "FermAct");
01042       param.invParam = readXMLGroup(paramtop, "InvertParam", "invType");
01043 
01044       read(paramtop, "quarkSpinType", param.quarkSpinType); // quark spin components
01045     }
01046     break;
01047 
01048     default:
01049       /**************************************************************************/
01050       QDPIO::cerr << "ChromaMultiProp parameter version " << version 
01051                   << " unsupported." << endl;
01052       QDP_abort(1);
01053     }
01054 
01055 //    // Sanity check. No of residuals must be same as no of masses
01056 //    if ( param.MultiMasses.size() != param.invParam.RsdCG.size() ) { 
01057 //      QDPIO::cerr << "Number of Masses in param.MultiMasses (" 
01058 //                << param.MultiMasses.size() 
01059 //                << ") differs from no of RsdCGs in param.invParam.RsdCG (" 
01060 //                << param.invParam.RsdCG.size() << ")" << endl;
01061 //
01062 //      QDP_abort(1);
01063 //    }
01064 
01065   }
01066 
01067 
01068   //-------------- HACK ----------------//
01069   // Fake gauge header reader. Need a proper solution
01070   void readGaugeHeader(XMLReader& paramtop, const std::string& path, std::string& gauge_header)
01071   {
01072     // Need to fix this and get proper headers
01073     if (paramtop.count("Config_info") > 0)
01074     {
01075       XMLReader xml_tmp(paramtop, "Config_info");
01076       std::ostringstream os;
01077       xml_tmp.printCurrentContext(os);
01078       gauge_header = os.str();
01079     }
01080     else
01081     {
01082       XMLBufferWriter xml_tmp;
01083       push(xml_tmp, "Config_info");
01084       pop(xml_tmp);
01085       gauge_header = xml_tmp.str();
01086     }
01087 
01088   }
01089 
01090 
01091   //=================================================================================
01092   // Propagator header readers and writers
01093 
01094   // MakeSourceProp reader
01095   void read(XMLReader& xml, const std::string& path, MakeSourceProp_t& param)
01096   {
01097     XMLReader paramtop(xml, path);
01098 
01099     read(paramtop, "PropSource", param.source_header);
01100     readGaugeHeader(paramtop, "Config_info", param.gauge_header);
01101   }
01102 
01103 
01104   // Propagator reader
01105   void read(XMLReader& xml, const string& path, Propagator_t& param)
01106   {
01107     XMLReader paramtop(xml, path);
01108 
01109     read(paramtop, "ForwardProp", param.prop_header);
01110     read(paramtop, "PropSource", param.source_header);
01111     readGaugeHeader(paramtop, "Config_info", param.gauge_header);
01112   }
01113 
01114 
01115   // ForwardProp reader
01116   void read(XMLReader& xml, const string& path, ForwardProp_t& param)
01117   {
01118     XMLReader paramtop(xml, path);
01119 
01120     read(paramtop, "PropSink", param.sink_header);
01121     read(paramtop, "ForwardProp", param.prop_header);
01122     read(paramtop, "PropSource", param.source_header);
01123     readGaugeHeader(paramtop, "Config_info", param.gauge_header);
01124   }
01125 
01126 
01127   // SequentialSource header reader
01128   void read(XMLReader& xml, const string& path, SequentialSource_t& param)
01129   {
01130     XMLReader paramtop(xml, path);
01131 
01132     read(paramtop, "SeqSourceSinkSmear", param.sink_header);
01133     read(paramtop, "SeqSource", param.seqsource_header);
01134     read(paramtop, "ForwardProps", param.forward_props);
01135     readGaugeHeader(paramtop, "Config_info", param.gauge_header);
01136   }
01137 
01138 
01139   // SequentialProp header reader
01140   void read(XMLReader& xml, const string& path, SequentialProp_t& param)
01141   {
01142     XMLReader paramtop(xml, path);
01143 
01144     read(paramtop, "SeqProp", param.seqprop_header);
01145     read(paramtop, "SeqSourceSinkSmear", param.sink_header);
01146     read(paramtop, "SeqSource", param.seqsource_header);
01147     read(paramtop, "ForwardProps", param.forward_props);
01148     readGaugeHeader(paramtop, "Config_info", param.gauge_header);
01149   }
01150 
01151 
01152   //! Source/sink spin indices
01153   void read(XMLReader& xml, const string& path, QQQSpinIndices_t& input)
01154   {
01155     XMLReader inputtop(xml, path);
01156 
01157     read(inputtop, "source", input.source);
01158     read(inputtop, "sink", input.sink);
01159   }
01160 
01161 
01162   // Initialize header with default values
01163   QQDiquark_t::QQDiquark_t()
01164   {
01165     Dirac_basis = true;
01166     forward_props.resize(2);
01167   }
01168 
01169 
01170   //! QQDiquark header reader
01171   void read(XMLReader& xml, const string& path, QQDiquark_t& param)
01172   {
01173     XMLReader paramtop(xml, path);
01174 
01175     int version;
01176     read(paramtop, "version", version);
01177 
01178     switch (version) 
01179     {
01180     case 1:
01181       break;
01182 
01183     default:
01184       QDPIO::cerr << "QQDiquark parameter version " << version 
01185                   << " unsupported." << endl;
01186       QDP_abort(1);
01187     }
01188 
01189     read(paramtop, "Dirac_basis", param.Dirac_basis);
01190     read(paramtop, "ForwardProps", param.forward_props);
01191     if (param.forward_props.size() != 2)
01192     {
01193       QDPIO::cerr << "QQDiquark: unexpected number of forward_props = " 
01194                   << param.forward_props.size() << endl; 
01195       QDP_abort(1);
01196     }
01197   }
01198 
01199 
01200   //! QQQBarcomp header reader
01201   void read(XMLReader& xml, const string& path, QQQBarcomp_t& param)
01202   {
01203     XMLReader paramtop(xml, path);
01204 
01205     int version = 1;
01206     if (paramtop.count("version") != 0)
01207       read(paramtop, "version", version);
01208 
01209     switch (version) 
01210     {
01211     case 1:
01212       param.sparseP = false;
01213       param.Dirac_basis = false;
01214       param.forward_props.resize(3);
01215       read(paramtop, "Propagator1", param.forward_props[0]);
01216       read(paramtop, "Propagator2", param.forward_props[1]);
01217       read(paramtop, "Propagator3", param.forward_props[2]);
01218       break;
01219 
01220     case 2:
01221       param.sparseP = false;
01222       read(paramtop, "Dirac_basis", param.Dirac_basis);
01223       read(paramtop, "ForwardProps", param.forward_props);
01224       break;
01225 
01226     case 3:
01227       read(paramtop, "sparseP", param.sparseP);
01228       read(paramtop, "Dirac_basis", param.Dirac_basis);
01229       read(paramtop, "ForwardProps", param.forward_props);
01230       break;
01231 
01232     default:
01233       /**************************************************************************/
01234       QDPIO::cerr << "QQQBarcomp parameter version " << version 
01235                   << " unsupported." << endl;
01236       QDP_abort(1);
01237     }
01238 
01239     if (param.sparseP)
01240     {
01241       read(paramtop, "SpinIndices", param.spin_indices);
01242     }
01243 
01244     if (param.forward_props.size() != 3)
01245     {
01246       QDPIO::cerr << "QQQBarcomp: unexpected number of forward_props = " 
01247                   << param.forward_props.size() << endl; 
01248       QDP_abort(1);
01249     }
01250   }
01251 
01252 
01253   //! QQbarMescomp header reader
01254   void read(XMLReader& xml, const string& path, QQbarMescomp_t& param)
01255   {
01256     XMLReader paramtop(xml, path);
01257 
01258     int version = 2;
01259 
01260     switch (version) 
01261     {
01262       /**************************************************************************/
01263     case 2:
01264       read(paramtop, "Dirac_basis", param.Dirac_basis);
01265       read(paramtop, "ForwardProps", param.forward_props);
01266       break;
01267 
01268     default:
01269       /**************************************************************************/
01270       QDPIO::cerr << "QQbarMescomp parameter version " << version 
01271                   << " unsupported." << endl;
01272       QDP_abort(1);
01273     }
01274 
01275     if (param.forward_props.size() != 2)
01276     {
01277       QDPIO::cerr << "QQbarMescomp: unexpected number of forward_props = " 
01278                   << param.forward_props.size() << endl; 
01279       QDP_abort(1);
01280     }
01281   }
01282 
01283 
01284 
01285 
01286   //---------------------------------------------------------------------------
01287   // Source header writer
01288   void write(XMLWriter& xml, const string& path, const PropSourceConst_t& header)
01289   {
01290     push(xml, path);
01291 
01292     int version = 6;
01293     write(xml, "version", version);
01294     xml << header.source.xml;
01295     write(xml, "j_decay", header.j_decay);   // I think these two are duplicates of what
01296     write(xml, "t_source", header.t_source); // is in header.source
01297 
01298     pop(xml);
01299   }
01300 
01301 
01302   // Source header writer
01303   void write(XMLWriter& xml, const string& path, const PropSourceSmear_t& header)
01304   {
01305     push(xml, path);
01306 
01307     int version = 6;
01308     write(xml, "version", version);
01309     xml << header.source.xml;
01310     write(xml, "j_decay", header.j_decay);
01311 
01312     pop(xml);
01313   }
01314 
01315 
01316   // Source header writer
01317   void write(XMLWriter& xml, const string& path, const PropSinkSmear_t& header)
01318   {
01319     push(xml, path);
01320 
01321     int version = 5;
01322     write(xml, "version", version);
01323     xml << header.sink.xml;
01324     write(xml, "j_decay", header.j_decay);
01325 
01326     pop(xml);
01327   }
01328 
01329 
01330   // Write propagator inversion parameters
01331   void write(XMLWriter& xml, const string& path, const ChromaProp_t& header)
01332   {
01333     push(xml, path);
01334 
01335     int version = 9;
01336     write(xml, "version", version);
01337     write(xml, "quarkSpinType", header.quarkSpinType);
01338     write(xml, "obsvP", header.obsvP);           // new - measured 5D stuff
01339     xml << header.fermact.xml;
01340     xml << header.invParam.xml;
01341 
01342     pop(xml);
01343   }
01344 
01345   // Write propagator inversion parameters
01346   void write(XMLWriter& xml, const string& path, const ChromaMultiProp_t& header)
01347   {
01348     push(xml, path);
01349 
01350     int version = 8;
01351     write(xml, "version", version);
01352     write(xml, "quarkSpinType", header.quarkSpinType);
01353     write(xml, "MultiMasses", header.MultiMasses);
01354     xml << header.fermact.xml;
01355     xml << header.invParam.xml;
01356 
01357     pop(xml);
01358   }
01359 
01360 
01361   //! SeqSource header writer
01362   void write(XMLWriter& xml, const string& path, const SeqSource_t& param)
01363   {
01364     push(xml, path);
01365 
01366     int version = 2;
01367     write(xml, "version", version);
01368     xml << param.seqsrc.xml;
01369 
01370     pop(xml);
01371   }
01372 
01373 
01374   // MakeSourceProp writer
01375   void write(XMLWriter& xml, const std::string& path, const MakeSourceProp_t& param)
01376   {
01377     push(xml, path);
01378 
01379     int version = 1;
01380     write(xml, "version", version);
01381     write(xml, "PropSource", param.source_header);
01382     write(xml, "Config_info", param.gauge_header);
01383 
01384     pop(xml);
01385   }
01386 
01387 
01388   // Propagator writer
01389   void write(XMLWriter& xml, const string& path, const Propagator_t& param)
01390   {
01391     push(xml, path);
01392 
01393     int version = 1;
01394     write(xml, "version", version);
01395     write(xml, "ForwardProp", param.prop_header);
01396     write(xml, "PropSource", param.source_header);
01397     write(xml, "Config_info", param.gauge_header);
01398 
01399     pop(xml);
01400   }
01401 
01402 
01403   // ForwardProp writer
01404   void write(XMLWriter& xml, const string& path, const ForwardProp_t& param)
01405   {
01406 //    if( path != "." )
01407     push(xml, path);
01408 
01409     int version = 1;
01410     write(xml, "version", version);
01411     write(xml, "PropSink", param.sink_header);
01412     write(xml, "ForwardProp", param.prop_header);
01413     write(xml, "PropSource", param.source_header);
01414     write(xml, "Config_info", param.gauge_header);
01415 
01416 //    if( path != "." )
01417     pop(xml);
01418   }
01419 
01420 
01421   //! SequentialSource header writer
01422   void write(XMLWriter& xml, const string& path, const SequentialSource_t& param)
01423   {
01424 //    if( path != "." )
01425     push(xml, path);
01426 
01427     int version = 1;
01428     write(xml, "version", version);
01429     write(xml, "SeqSourceSinkSmear", param.sink_header);
01430     write(xml, "SeqSource", param.seqsource_header);
01431     write(xml, "ForwardProps", param.forward_props);
01432     write(xml, "Config_info", param.gauge_header);
01433 
01434 //    if( path != "." )
01435     pop(xml);
01436   }
01437 
01438 
01439   //! SequentialProp header writer
01440   void write(XMLWriter& xml, const string& path, const SequentialProp_t& param)
01441   {
01442 //    if( path != "." )
01443     push(xml, path);
01444 
01445     int version = 1;
01446     write(xml, "version", version);
01447     write(xml, "SeqProp", param.seqprop_header);
01448     write(xml, "SeqSourceSinkSmear", param.sink_header);
01449     write(xml, "SeqSource", param.seqsource_header);
01450     write(xml, "ForwardProps", param.forward_props);
01451     write(xml, "Config_info", param.gauge_header);
01452 
01453 //    if( path != "." )
01454     pop(xml);
01455   }
01456 
01457 
01458   //! Source/sink spin indices
01459   void write(XMLWriter& xml, const string& path, const QQQSpinIndices_t& input)
01460   {
01461     push(xml, path);
01462 
01463     write(xml, "source", input.source);
01464     write(xml, "sink", input.sink);
01465 
01466     pop(xml);
01467   }
01468 
01469 
01470   //! QQDiquark header writer
01471   void write(XMLWriter& xml, const string& path, const QQDiquark_t& param)
01472   {
01473     if( path != "." )
01474       push(xml, path);
01475 
01476     int version = 1;
01477     write(xml, "version", version);
01478     write(xml, "Dirac_basis", param.Dirac_basis);
01479     write(xml, "ForwardProps", param.forward_props);
01480 
01481     if( path != "." )
01482       pop(xml);
01483   }
01484 
01485 
01486   //! QQQBarcomp header writer
01487   void write(XMLWriter& xml, const string& path, const QQQBarcomp_t& param)
01488   {
01489     if( path != "." )
01490       push(xml, path);
01491 
01492     int version = 3;
01493     write(xml, "version", version);
01494     write(xml, "sparseP", param.sparseP);
01495     write(xml, "Dirac_basis", param.Dirac_basis);
01496     if (param.sparseP)
01497     {
01498       write(xml, "SpinIndices", param.spin_indices);
01499     }
01500     write(xml, "ForwardProps", param.forward_props);
01501 
01502     if( path != "." )
01503       pop(xml);
01504   }
01505 
01506 
01507   //! QQbarMescomp header writer
01508   void write(XMLWriter& xml, const string& path, const QQbarMescomp_t& param)
01509   {
01510     if( path != "." )
01511       push(xml, path);
01512 
01513     int version = 2;
01514     write(xml, "version", version);
01515     write(xml, "Dirac_basis", param.Dirac_basis);
01516     write(xml, "ForwardProps", param.forward_props);
01517 
01518     if( path != "." )
01519       pop(xml);
01520   }
01521 
01522 
01523 
01524   // Write a Chroma propagator
01525   /*
01526    * \param file_xml     file header ( Read )
01527    * \param record_xml   xml holding propagator info ( Read )
01528    * \param quark_prop   propagator ( Read )
01529    * \param file         path ( Read )
01530    * \param volfmt       either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
01531    * \param serpar       either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
01532    */    
01533   void writeQprop(XMLBufferWriter& file_xml,
01534                   XMLBufferWriter& record_xml, const LatticePropagator& quark_prop,
01535                   const string& file, 
01536                   QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
01537   {
01538     QDPFileWriter to(file_xml,file,volfmt,serpar,QDPIO_OPEN);
01539     write(to,record_xml,quark_prop);
01540     close(to);
01541   }
01542 
01543 
01544   // Write a Chroma propagator
01545   /*
01546    * \param file_xml     file header ( Read )
01547    * \param header       structure holding propagator info ( Read )
01548    * \param quark_prop   propagator ( Read )
01549    * \param file         path ( Read )
01550    * \param volfmt       either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
01551    * \param serpar       either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
01552    */    
01553   void writeQprop(XMLBufferWriter& file_xml,
01554                   const ChromaProp_t& header, const LatticePropagator& quark_prop,
01555                   const string& file, 
01556                   QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
01557   {
01558     XMLBufferWriter record_xml;
01559     write(record_xml, "Propagator", header);
01560     writeQprop(file_xml, record_xml, quark_prop, file, volfmt, serpar);
01561   }
01562 
01563 
01564 
01565 
01566   // Read a Chroma propagator
01567   /*
01568    * \param file_xml     file header ( Write )
01569    * \param record_xml   xml holding propagator info ( Write )
01570    * \param quark_prop   propagator ( Write )
01571    * \param file         path ( Read )
01572    * \param serpar       either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
01573    */    
01574   void readQprop(XMLReader& file_xml,
01575                  XMLReader& record_xml, LatticePropagator& quark_prop,
01576                  const string& file, 
01577                  QDP_serialparallel_t serpar)
01578   {
01579     QDPFileReader to(file_xml,file,serpar);
01580     read(to,record_xml,quark_prop);
01581     close(to);
01582   }
01583 
01584   // Read a Chroma propagator
01585   /*
01586    * \param file_xml     file header ( Write )
01587    * \param header       structure holding propagator info ( Write )
01588    * \param quark_prop   propagator ( Write )
01589    * \param file         path ( Read )
01590    * \param serpar       either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
01591    */    
01592   void readQprop(XMLReader& file_xml,
01593                  ChromaProp_t& header, LatticePropagator& quark_prop,
01594                  const string& file, 
01595                  QDP_serialparallel_t serpar)
01596   {
01597     XMLReader record_xml;
01598     readQprop(file_xml, record_xml, quark_prop, file, serpar);
01599     read(record_xml, "/Propagator", header);  // extract header from xml
01600   }
01601 
01602 
01603 
01604 
01605   // Write a Chroma Fermion Field (eg prop_component)
01606   /*
01607    * \param file_xml     file header ( Read )
01608    * \param record_xml   xml holding propagator info ( Read )
01609    * \param fermion      fermion field( Read )
01610    * \param file         path ( Read )
01611    * \param volfmt       either QDPIO_SINGLEFILE, QDPIO_MULTIFILE ( Read )
01612    * \param serpar       either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
01613    */    
01614   void writeFermion(XMLBufferWriter& file_xml,
01615                     XMLBufferWriter& record_xml, const LatticeFermion& fermion,
01616                     const string& file, 
01617                     QDP_volfmt_t volfmt, QDP_serialparallel_t serpar)
01618   {
01619     QDPFileWriter to(file_xml,file,volfmt,serpar,QDPIO_OPEN);
01620     write(to,record_xml,fermion);
01621     close(to);
01622   }
01623 
01624   // Read a Chroma Fermion Field
01625   /*
01626    * \param file_xml     file header ( Write )
01627    * \param record_xml   xml holding propagator info ( Write )
01628    * \param fermion      The Fermion ( Write )
01629    * \param file         path ( Read )
01630    * \param serpar       either QDPIO_SERIAL, QDPIO_PARALLEL ( Read )
01631    */    
01632   void readFermion(XMLReader& file_xml,
01633                    XMLReader& record_xml, 
01634                    LatticeFermion& fermion,
01635                    const string& file, 
01636                    QDP_serialparallel_t serpar)
01637   {
01638     QDPFileReader to(file_xml,file,serpar);
01639     read(to,record_xml,fermion);
01640     close(to);
01641   }
01642 
01643 }  // end namespace Chroma
01644 

Generated on Sun Nov 22 04:34:07 2009 for CHROMA by  doxygen 1.4.7