Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

alg_s_spect.C

Go to the documentation of this file.
00001 #include<config.h>
00002 CPS_START_NAMESPACE
00003 //--------------------------------------------------------------------
00004 //  CVS keywords
00005 //
00006 //  $Author: chulwoo $
00007 //  $Date: 2008/02/08 18:35:05 $
00008 //  $Header: /space/cvs/cps/cps++/src/alg/alg_s_spect/alg_s_spect.C,v 1.13 2008/02/08 18:35:05 chulwoo Exp $
00009 //  $Id: alg_s_spect.C,v 1.13 2008/02/08 18:35:05 chulwoo Exp $
00010 //  $Name: v5_0_8 $
00011 //  $Locker:  $
00012 //  $RCSfile: alg_s_spect.C,v $
00013 //  $Revision: 1.13 $
00014 //  $Source: /space/cvs/cps/cps++/src/alg/alg_s_spect/alg_s_spect.C,v $
00015 //  $State: Exp $
00016 //
00017 //--------------------------------------------------------------------
00018 //------------------------------------------------------------------
00019 //
00020 // alg_s_spect.C
00021 //
00022 // Code for all alg classes relevant to staggered fermion
00023 // spectroscopy. The type of glue or fermion is given as
00024 // an argument of type Lattice& to the constructor. If the 
00025 // fermion type is not F_CLASS_STAG the constructors exit with
00026 // a general error.
00027 //
00028 //------------------------------------------------------------------
00029 
00030 
00031 CPS_END_NAMESPACE
00032 #include <util/qcdio.h>
00033 #include <alg/quark_prop_s.h>
00034 #include <alg/meson_prop_s.h>
00035 #include <alg/mom_meson_p_s.h>
00036 #include <alg/nucl_prop_s.h>
00037 #include <alg/nlocal_prop_s.h>
00038 #include <alg/nlocal_propmes_s.h>
00039 #include <alg/aots_s.h>
00040 #include <alg/alg_s_spect.h>
00041 #include <alg/common_arg.h>
00042 #include <alg/s_spect_arg.h>
00043 #include <util/lattice.h>
00044 #include <util/gjp.h>
00045 #include <util/smalloc.h>
00046 #include <util/vector.h>
00047 #include <util/verbose.h>
00048 #include <util/error.h>
00049 #include <alg/myenum.h>
00050 
00051 #ifdef PARALLEL
00052 #include <comms/sysfunc_cps.h>
00053 #endif
00054 
00055 CPS_START_NAMESPACE
00056 
00057 QuarkPropSMng AlgStagQuark::sqpm;
00058 
00059 static char *class_str = "Class type was %d instead of F_CLASS_STAG";
00060 
00061 static void zero_buffer(Float *buf, int len)
00062 { 
00063   for(int i = 0; i < len; i++)
00064     *buf++ = 0;
00065 }
00066 
00067 static void write_to_file(const Float *data_p, FILE *fp, 
00068                           int num_IFloats, int num_slices, int mom, 
00069                           HadronType type, BndCndType bc)
00070 {
00071 
00072 #if TARGET==cpsMPI
00073     using MPISCU::fprintf;
00074 #endif
00075 
00076   // printf("write_to_file: no_of_momenta = %d \n",mom);
00077   int unit;
00078   switch(type) {
00079     case SMESON:
00080         unit = 4; break;
00081     case SMOMMESON:
00082         unit = 4*mom; break;
00083     case SNUCLEON: 
00084         unit = 1; break;
00085     case SNONLOCAL:
00086         unit = 4; break;
00087     default: 
00088         unit = 0; break;
00089   }
00090 
00091   
00092   int i, k;
00093 
00094   //-------------------------------------------------------------
00095   // for the Non Local staggered meson, just print out every result!
00096   // other modification is done by anlysis script 
00097   //-------------------------------------------------------------
00098   if (type == NLSTAG) {
00099    Float tmp;    
00100     for(i = 0 ; i < num_IFloats ; i+=2) {
00101       //printf("i = %d\n",i);
00102       tmp = data_p[i] / num_slices;
00103       Fprintf(fp,"%e    ",(IFloat)tmp);
00104       tmp = data_p[i+1] / num_slices;
00105       Fprintf(fp,"%e\n",(IFloat)tmp);
00106       //printf("data_p[%d] = %f data_p[%d] = %f\n",i,data_p[i]/num_slices,i+1,data_p[i+1]/num_slices);
00107     }
00108     return ;
00109   }
00110   //-------------------------------------------------------------
00111   // * write C(t = 0)
00112   //-------------------------------------------------------------
00113   for (i = 0; i < unit; ++i) {
00114     Float tmp = data_p[2*i] / num_slices;
00115     Fprintf(fp, "%e\n", (IFloat)tmp);
00116   }
00117   
00118   //-------------------------------------------------------------
00119   // * write (C(t) + C(N_t-t))/2 for t = 1 to (N_t/2)-1
00120   //-------------------------------------------------------------
00121   int half_length = num_IFloats / 4;
00122   int N_t = num_IFloats / (2*unit);
00123   
00124   if (type == SMESON || type == SMOMMESON) {
00125     for (i = unit; i < half_length; ++i) {
00126       k = unit*(N_t - i/unit) + i%unit;
00127       Float tmp = (data_p[2*i] + data_p[2*k])*0.5/num_slices;
00128       Fprintf(fp, "%e\n", (IFloat)tmp);
00129     }
00130   }
00131   else if (bc == BND_CND_APRD)  {
00132     for (i = unit; i < half_length; ++i) {
00133       k = unit*(N_t - i/unit) + i%unit;
00134       Float tmp;
00135 
00136       if (((i/unit) % 2) == 0)
00137         tmp = (data_p[2*i] - data_p[2*k])*0.5/num_slices;
00138       else
00139         tmp = (data_p[2*i] + data_p[2*k])*0.5/num_slices;
00140 
00141       Fprintf(fp, "%e\n", (IFloat)tmp);
00142     }
00143   }
00144 
00145   else {
00146     for (i = unit; i < half_length; ++i) {
00147       k = unit*(N_t - i/unit) + i%unit;
00148       Float tmp;
00149 
00150       if (((i/unit) % 2) == 0)
00151         tmp = (data_p[2*i] + data_p[2*k])*0.5/num_slices;
00152       else
00153         tmp = (data_p[2*i] - data_p[2*k])*0.5/num_slices;
00154 
00155       Fprintf(fp, "%e\n", (IFloat)tmp);
00156     }
00157   }
00158 
00159   //-------------------------------------------------------------
00160   // * write C(t=N_t/2)
00161   //-------------------------------------------------------------
00162   for (i = half_length; i < half_length + unit; ++i) {
00163     Float tmp = data_p[2*i] / num_slices;
00164     Fprintf(fp, "%e\n", (IFloat)tmp);
00165   }
00166 }
00167   
00168 //------------------------------------------------------------------
00169 //------------------------------------------------------------------
00170 //
00171 // AlgStagQuark is derived from Alg and is relevant to  
00172 // the staggered quark propagator.
00173 // The type of fermion is determined by the argument to the 
00174 // constructor. If the fermion type is not F_CLASS_STAG the 
00175 // constructor will exit with a general error.
00176 //
00177 //------------------------------------------------------------------
00178 //------------------------------------------------------------------
00179 
00180 //------------------------------------------------------------------
00181 // Constructor 
00182 //------------------------------------------------------------------
00183 AlgStagQuark::AlgStagQuark(Lattice& latt, 
00184                            CommonArg *c_arg,
00185                            StagQuarkArg *arg, Aots &aots) 
00186 : Alg(latt, c_arg)
00187 {
00188   cname = "AlgStagQuark";
00189   char *fname = "AlgStagQuark(L&,CommonArg*,StagQuarkArg*)";
00190   VRB.Func(cname,fname);
00191 
00192   // Check fermion type
00193   //----------------------------------------------------------------
00194   if(!latt.FstagType())
00195     ERR.General(cname,fname, class_str, int(latt.Fclass()));
00196 
00197 
00198   // Initialize the argument pointer
00199   //----------------------------------------------------------------
00200   if(arg == 0)
00201     ERR.Pointer(cname,fname, "arg");
00202 
00203   arg->src.origin[arg->src.dir] = arg->src.end[arg->src.dir] = aots.slice();
00204   alg_stag_quark_arg = arg;
00205 }
00206 
00207 
00208 //------------------------------------------------------------------
00209 // Destructor
00210 //------------------------------------------------------------------
00211 AlgStagQuark::~AlgStagQuark() {
00212   char *fname = "~AlgStagQuark()";
00213   VRB.Func(cname,fname);
00214 }
00215 
00216 
00217 //------------------------------------------------------------------
00218 // Calculate propagator
00219 //------------------------------------------------------------------
00220 void AlgStagQuark::run()
00221 {
00222   char *fname = "run()";
00223   VRB.Func(cname,fname);
00224 
00225   // Set the Lattice pointer
00226   //----------------------------------------------------------------
00227   Lattice& lat = AlgLattice();
00228 
00229   QuarkPropS q1(lat, *alg_stag_quark_arg);
00230   q1.setupQuarkPropS();
00231   q1.getQuarkPropS((char *)common_arg->results);
00232 }
00233 
00234 
00235 //------------------------------------------------------------------
00236 // Destroy propagator
00237 //------------------------------------------------------------------
00238 void AlgStagQuark::free()
00239 {
00240   char *fname = "destroy()";
00241   VRB.Func(cname,fname);
00242 
00243   // Set the Lattice pointer
00244   //----------------------------------------------------------------
00245 //  Lattice& lat = AlgLattice();
00246 
00247   sqpm.destroyQuarkPropS(alg_stag_quark_arg->qid);
00248 }
00249 
00250 
00251 
00252 //------------------------------------------------------------------
00253 //------------------------------------------------------------------
00254 //
00255 // AlgStagMeson is derived from Alg and is relevant to  
00256 // the staggered meson propagator.
00257 // The type of fermion is determined by the argument to the 
00258 // constructor. If the fermion type is not F_CLASS_STAG the 
00259 // constructor will exit with a general error.
00260 //
00261 //------------------------------------------------------------------
00262 //------------------------------------------------------------------
00263 
00264 //------------------------------------------------------------------
00265 // Constructor 
00266 //------------------------------------------------------------------
00267 AlgStagMeson::AlgStagMeson(Lattice& latt, 
00268                            CommonArg *c_arg,
00269                            StagMesonArg *arg, Aots& a) 
00270 :   Alg(latt, c_arg), aots(a) 
00271 {
00272   cname = "AlgStagMeson";
00273   char *fname = "AlgStagMeson(L&,CommonArg*,StagMesonArg*)";
00274   VRB.Func(cname,fname);
00275 
00276   // Check fermion type
00277   //----------------------------------------------------------------
00278   if(!latt.FstagType())
00279     ERR.General(cname,fname, class_str, int(latt.Fclass()));
00280 
00281   
00282   // Initialize the argument pointer
00283   //----------------------------------------------------------------
00284   if(arg == 0)
00285     ERR.Pointer(cname,fname, "arg");
00286   alg_stag_meson_arg = arg;
00287 }
00288 
00289 
00290 //------------------------------------------------------------------
00291 // Destructor
00292 //------------------------------------------------------------------
00293 AlgStagMeson::~AlgStagMeson() {
00294   char *fname = "~AlgStagMeson()";
00295   VRB.Func(cname,fname);
00296 }
00297 
00298 
00299 //------------------------------------------------------------------
00300 // Calculate propagator
00301 //------------------------------------------------------------------
00302 void AlgStagMeson::run()
00303 {
00304   char *fname = "run()";
00305   VRB.Func(cname,fname);
00306 
00307   // Set the Lattice pointer
00308   //----------------------------------------------------------------
00309   Lattice& lat = AlgLattice();
00310 
00311   MesonPropS m1(lat, *alg_stag_meson_arg);
00312   m1.getHadronPropS();
00313 
00314   // download propagator and AOTS 
00315   //----------------------------------------------------------------
00316   if(aots.begin()) {
00317     alg_stag_meson_arg->meson_buf = 
00318                 (unsigned long)smalloc(m1.propLenTotal()*sizeof(Float));
00319     if(alg_stag_meson_arg->meson_buf == 0)
00320           ERR.Pointer(cname,fname, "alg_stag_meson_arg->meson_buf");
00321     VRB.Smalloc(cname,fname, "alg_stag_meson_arg->meson_buf", 
00322                 (void *)alg_stag_meson_arg->meson_buf, m1.propLenTotal()*sizeof(Float));
00323     zero_buffer((Float *)alg_stag_meson_arg->meson_buf, m1.propLenTotal());
00324   }
00325 
00326   m1.download_prop(SMESON, (Float *)alg_stag_meson_arg->meson_buf);
00327 
00328   if (aots.last()) {
00329     char *data_file = common_arg->results ? 
00330                       (char *)common_arg->results : CAST_AWAY_CONST("meson.def"); 
00331     FILE *fp;
00332     if( NULL == (fp = Fopen(data_file, "a")) ) {
00333       ERR.FileA(cname,fname, data_file);
00334     }
00335 
00336     write_to_file((Float *)alg_stag_meson_arg->meson_buf, fp, 
00337                   m1.propLenTotal(), aots.numSlices(), 1, SMESON, m1.bcd());
00338     Fclose(fp);
00339 
00340     VRB.Sfree(cname,fname, "alg_stag_meson_arg->meson_buf", 
00341                             (void *)alg_stag_meson_arg->meson_buf);
00342     sfree((Float *)alg_stag_meson_arg->meson_buf);
00343     alg_stag_meson_arg->meson_buf = 0;
00344   }
00345 }
00346 
00347 
00348 
00349 //------------------------------------------------------------------
00350 //------------------------------------------------------------------
00351 //
00352 // AlgStagMomMeson is derived from Alg and is relevant to
00353 // the staggered meson propagator.
00354 // The type of fermion is determined by the argument to the
00355 // constructor. If the fermion type is not F_CLASS_STAG the
00356 // constructor will exit with a general error.
00357 //
00358 //------------------------------------------------------------------
00359 //------------------------------------------------------------------
00360 
00361 //------------------------------------------------------------------
00362 // Constructor
00363 //------------------------------------------------------------------
00364 AlgStagMomMeson::AlgStagMomMeson(Lattice& latt,
00365                            CommonArg *c_arg,
00366                            StagMomMesonArg *arg, Aots& a)
00367 :   Alg(latt, c_arg), aots(a)
00368 {
00369   cname = "AlgStagMomMeson";
00370   char *fname = "AlgStagMomMeson(L&,CommonArg*,StagMomMesonArg*, Aots& )";
00371   VRB.Func(cname,fname);
00372 
00373   // Check fermion type
00374   //----------------------------------------------------------------
00375   if(!latt.FstagType())
00376     ERR.General(cname,fname, class_str, int(latt.Fclass()));
00377 
00378 
00379   // Initialize the argument pointer
00380   //----------------------------------------------------------------
00381   if(arg == 0)
00382     ERR.Pointer(cname,fname, "arg");
00383   alg_stag_mom_meson_arg = arg;
00384 }
00385 
00386 
00387 //------------------------------------------------------------------
00388 // Destructor
00389 //------------------------------------------------------------------
00390 AlgStagMomMeson::~AlgStagMomMeson() {
00391   char *fname = "~AlgStagMomMeson()";
00392   VRB.Func(cname,fname);
00393 }
00394 
00395 
00396 //------------------------------------------------------------------
00397 // Calculate propagator
00398 //------------------------------------------------------------------
00399 void AlgStagMomMeson::run()
00400 {
00401   char *fname = "run()";
00402   VRB.Func(cname,fname);
00403 
00404   // Set the Lattice pointer
00405   //----------------------------------------------------------------
00406   Lattice& lat = AlgLattice();
00407 
00408   MomMesonPropS m1(lat, *alg_stag_mom_meson_arg);
00409   m1.getHadronPropS();
00410 
00411   // download propagator and AOTS
00412   //----------------------------------------------------------------
00413   if(aots.begin()) {
00414     alg_stag_mom_meson_arg->meson_buf =
00415       (unsigned long)smalloc(m1.propLenTotal()*sizeof(Float));
00416     if(alg_stag_mom_meson_arg->meson_buf == 0)
00417       ERR.Pointer(cname,fname, "alg_stag_mom_meson_arg->meson_buf");
00418     VRB.Smalloc(cname,fname, "alg_stag_mom_meson_arg->meson_buf",
00419          (void *)alg_stag_mom_meson_arg->meson_buf, m1.propLenTotal()*sizeof(Float));
00420     zero_buffer((Float *)alg_stag_mom_meson_arg->meson_buf, m1.propLenTotal());
00421   }
00422 
00423 
00424   m1.download_prop(SMOMMESON, (Float *)alg_stag_mom_meson_arg->meson_buf);
00425 
00426   if (aots.last()) {
00427     char *data_file = common_arg->results ?
00428                       (char *)common_arg->results : (char *) "mom_meson.def";
00429     FILE *fp;
00430     if( NULL == (fp = Fopen(data_file, "a")) ) {
00431       ERR.FileA(cname,fname, data_file);
00432     }
00433 
00434     write_to_file((Float *)alg_stag_mom_meson_arg->meson_buf, fp,
00435                   m1.propLenTotal(), aots.numSlices(), 
00436         alg_stag_mom_meson_arg->no_of_momenta,SMOMMESON, m1.bcd());
00437     Fclose(fp);
00438 
00439     VRB.Sfree(cname,fname, "alg_stag_mom_meson_arg->meson_buf",
00440                             (void *)alg_stag_mom_meson_arg->meson_buf);
00441     sfree((void *)alg_stag_mom_meson_arg->meson_buf);
00442     alg_stag_mom_meson_arg->meson_buf = 0;
00443   }
00444 }
00445 
00446 
00447 
00448 //------------------------------------------------------------------
00449 //------------------------------------------------------------------
00450 //
00451 // AlgStagNucleon is derived from Alg and is relevant to  
00452 // the staggered nucleon propagator.
00453 // The type of fermion is determined by the argument to the 
00454 // constructor. If the fermion type is not F_CLASS_STAG the 
00455 // constructor will exit with a general error.
00456 //
00457 //------------------------------------------------------------------
00458 //------------------------------------------------------------------
00459 
00460 //------------------------------------------------------------------
00461 // Constructor 
00462 //------------------------------------------------------------------
00463 AlgStagNucleon::AlgStagNucleon(Lattice& latt, 
00464                                CommonArg *c_arg,
00465                                StagNucleonArg *arg, Aots& a) :
00466                                Alg(latt, c_arg), aots(a) 
00467 {
00468   cname = "AlgStagNucleon";
00469   char *fname = "AlgStagNucleon(L&,CommonArg*,StagNucleonArg*)";
00470   VRB.Func(cname,fname);
00471 
00472   // Check fermion type
00473   //----------------------------------------------------------------
00474   if(!latt.FstagType())
00475     ERR.General(cname,fname, class_str, int(latt.Fclass()));
00476 
00477 
00478   // Initialize the argument pointer
00479   //----------------------------------------------------------------
00480   if(arg == 0)
00481     ERR.Pointer(cname,fname, "arg");
00482   alg_stag_nucleon_arg = arg;
00483 }
00484 
00485 
00486 //------------------------------------------------------------------
00487 // Destructor
00488 //------------------------------------------------------------------
00489 AlgStagNucleon::~AlgStagNucleon() {
00490   char *fname = "~AlgStagNucleon()";
00491   VRB.Func(cname,fname);
00492 }
00493 
00494 
00495 //------------------------------------------------------------------
00496 // Calculate propagator
00497 //------------------------------------------------------------------
00498 void AlgStagNucleon::run()
00499 {
00500   char *fname = "run()";
00501   VRB.Func(cname,fname);
00502 
00503   // Set the Lattice pointer
00504   //----------------------------------------------------------------
00505   Lattice& lat = AlgLattice();
00506 
00507   NucleonPropS n1(lat, *alg_stag_nucleon_arg);
00508   n1.getHadronPropS();
00509 
00510   // download propagator and AOTS 
00511   //----------------------------------------------------------------
00512   if(aots.begin()) {
00513     alg_stag_nucleon_arg->nucleon_buf = 
00514                 (unsigned long)smalloc(n1.propLenTotal()*sizeof(Float));
00515     if(alg_stag_nucleon_arg->nucleon_buf == 0)
00516           ERR.Pointer(cname,fname, "alg_stag_nucleon_arg->nucleon_buf");
00517     VRB.Smalloc(cname,fname, "alg_stag_nucleon_arg->nucleon_buf", 
00518                 (void *)alg_stag_nucleon_arg->nucleon_buf, n1.propLenTotal()*sizeof(Float));
00519     zero_buffer((Float *)alg_stag_nucleon_arg->nucleon_buf, n1.propLenTotal());
00520   }
00521 
00522   n1.download_prop(SNUCLEON, (Float *)alg_stag_nucleon_arg->nucleon_buf);
00523 
00524   if (aots.last()) {
00525     char *data_file = common_arg->results ? 
00526                       (char *)common_arg->results : CAST_AWAY_CONST("nucleon.def"); 
00527     FILE *fp;
00528     if( NULL == (fp = Fopen(data_file, "a")) ) {
00529       ERR.FileA(cname,fname, data_file);
00530     }
00531    
00532     write_to_file((Float *)alg_stag_nucleon_arg->nucleon_buf, fp, 
00533                   n1.propLenTotal(), aots.numSlices(), 1, SNUCLEON, n1.bcd());
00534     Fclose(fp);
00535 
00536     VRB.Sfree(cname,fname, "alg_stag_nucleon_arg->nucleon_buf", 
00537                             (void *)alg_stag_nucleon_arg->nucleon_buf);
00538     sfree((void *)alg_stag_nucleon_arg->nucleon_buf);
00539     alg_stag_nucleon_arg->nucleon_buf = 0;
00540   }
00541 }
00542 
00543 
00544 
00545 //------------------------------------------------------------------
00546 //------------------------------------------------------------------
00547 //
00548 // AlgStagNonLocal is derived from Alg and is relevant to  
00549 // the staggered non-local hadron propagator.
00550 // The type of fermion is determined by the argument to the 
00551 // constructor. If the fermion type is not F_CLASS_STAG the 
00552 // constructor will exit with a general error.
00553 //
00554 //------------------------------------------------------------------
00555 //------------------------------------------------------------------
00556 
00557 //------------------------------------------------------------------
00558 // Constructor 
00559 //------------------------------------------------------------------
00560 AlgStagNonLocal::AlgStagNonLocal(Lattice& latt, 
00561                                  CommonArg *c_arg,
00562                                  StagNonLocalArg *arg, Aots& a) :
00563                                  Alg(latt, c_arg), aots(a) 
00564 {
00565   cname = "AlgStagNonLocal";
00566   char *fname = "AlgStagNonLocal(L&,CommonArg*,StagNonLocalArg*)";
00567   VRB.Func(cname,fname);
00568 
00569   // Check fermion type
00570   //----------------------------------------------------------------
00571   if(!latt.FstagType())
00572     ERR.General(cname,fname, class_str, int(latt.Fclass()));
00573 
00574 
00575   // Initialize the argument pointer
00576   //----------------------------------------------------------------
00577   if(arg == 0)
00578     ERR.Pointer(cname,fname, "arg");
00579   alg_stag_non_local_arg = arg;
00580 }
00581 
00582 
00583 //------------------------------------------------------------------
00584 // Destructor
00585 //------------------------------------------------------------------
00586 AlgStagNonLocal::~AlgStagNonLocal() {
00587   char *fname = "~AlgStagNonLocal()";
00588   VRB.Func(cname,fname);
00589 }
00590 
00591 
00592 //------------------------------------------------------------------
00593 // Calculate propagator
00594 //------------------------------------------------------------------
00595 void AlgStagNonLocal::run()
00596 {
00597   char *fname = "run()";
00598   VRB.Func(cname,fname);
00599 
00600   // Set the Lattice pointer
00601   //----------------------------------------------------------------
00602   Lattice& lat = AlgLattice();
00603 
00604   NLocalPropS nlc(lat, *alg_stag_non_local_arg);
00605   nlc.getHadronPropS();
00606 
00607   // download propagator and AOTS 
00608   //----------------------------------------------------------------
00609   if(aots.begin()) {
00610     alg_stag_non_local_arg->nlocal_buf = 
00611                 (unsigned long)smalloc(nlc.propLenTotal()*sizeof(Float));
00612 
00613     if(alg_stag_non_local_arg->nlocal_buf == 0)
00614           ERR.Pointer(cname,fname, "alg_stag_non_local_arg->nlocal_buf");
00615     VRB.Smalloc(cname,fname, "alg_stag_non_local_arg->nlocal_buf", 
00616                 (void *)alg_stag_non_local_arg->nlocal_buf, 
00617                 nlc.propLenTotal()*sizeof(Float));
00618 
00619     zero_buffer((Float *)alg_stag_non_local_arg->nlocal_buf, nlc.propLenTotal());
00620   }
00621 
00622   nlc.download_prop(SNONLOCAL, (Float *)alg_stag_non_local_arg->nlocal_buf);
00623 
00624   if (aots.last()) {
00625     char *data_file = common_arg->results ? 
00626                       (char *)common_arg->results : CAST_AWAY_CONST("nonlocal.def"); 
00627     FILE *fp;
00628     if( NULL == (fp = Fopen(data_file, "a")) ) {
00629       ERR.FileA(cname,fname, data_file);
00630     }
00631 
00632     write_to_file((Float *)alg_stag_non_local_arg->nlocal_buf, fp, 
00633                 nlc.propLenTotal(), aots.numSlices(), 1, SNONLOCAL, nlc.bcd());
00634     Fclose(fp);
00635 
00636     VRB.Sfree(cname,fname, "alg_stag_non_local_arg->nlocal_buf", 
00637                             (void *)alg_stag_non_local_arg->nlocal_buf);
00638     sfree((void *)alg_stag_non_local_arg->nlocal_buf);
00639     alg_stag_non_local_arg->nlocal_buf = 0;
00640   }
00641 }
00642 
00643 //------------------------------------------------------------------
00644 //------------------------------------------------------------------
00645 //
00646 // AlgNLStagMeson is derived from Alg and is relevant to  
00647 // the staggered non-local hadron propagator.
00648 // The type of fermion is determined by the argument to the 
00649 // constructor. If the fermion type is not F_CLASS_STAG the 
00650 // constructor will exit with a general error.
00651 // This class use NLMesonPropS class writted by chateau
00652 //
00653 //------------------------------------------------------------------
00654 //------------------------------------------------------------------
00655 
00656 //------------------------------------------------------------------
00657 // Constructor 
00658 //------------------------------------------------------------------
00659 AlgNLStagMeson::AlgNLStagMeson(Lattice& latt, 
00660                                  CommonArg *c_arg,
00661                                  NLStagMesonArg *arg, Aots& a) :
00662                                  Alg(latt, c_arg), aots(a) 
00663 {
00664   cname = "AlgNLStagMeson";
00665   char *fname = "AlgNLStagMeson(L&,CommonArg*,NLStagMesonArg*)";
00666   VRB.Func(cname,fname);
00667 
00668   // Check fermion type
00669   //----------------------------------------------------------------
00670   /*if(latt.Fclass() != F_CLASS_STAG)
00671     ERR.General(cname,fname, class_str, int(latt.Fclass()));*/
00672 
00673 
00674   // Initialize the argument pointer
00675   //----------------------------------------------------------------
00676   if(arg == 0)
00677     ERR.Pointer(cname,fname, "arg");
00678   alg_stag_non_local_arg = arg;
00679 }
00680 
00681 
00682 //------------------------------------------------------------------
00683 // Destructor
00684 //------------------------------------------------------------------
00685 AlgNLStagMeson::~AlgNLStagMeson() {
00686   char *fname = "~AlgNLStagMeson()";
00687   VRB.Func(cname,fname);
00688 }
00689 
00690 
00691 //------------------------------------------------------------------
00692 // Calculate propagator
00693 //------------------------------------------------------------------
00694 void AlgNLStagMeson::run()
00695 {
00696   char *fname = "run()";
00697   VRB.Func(cname,fname);
00698 
00699   // Set the Lattice pointer
00700   //----------------------------------------------------------------
00701   Lattice& lat = AlgLattice();
00702 
00703   NLSMesonPropS nlsm(lat, *alg_stag_non_local_arg);
00704   nlsm.getHadronPropS();
00705 
00706   // download propagator and AOTS 
00707   //----------------------------------------------------------------
00708   if(aots.begin()) {
00709     alg_stag_non_local_arg->nlocal_buf = 
00710                 (unsigned long)smalloc(nlsm.propLenTotal()*sizeof(Float));
00711 
00712     if(alg_stag_non_local_arg->nlocal_buf == 0)
00713           ERR.Pointer(cname,fname, "alg_stag_non_local_arg->nlocal_buf");
00714     VRB.Smalloc(cname,fname, "alg_stag_non_local_arg->nlocal_buf", 
00715                 (void *)alg_stag_non_local_arg->nlocal_buf, 
00716                 nlsm.propLenTotal()*sizeof(Float));
00717 
00718     zero_buffer((Float *)alg_stag_non_local_arg->nlocal_buf, nlsm.propLenTotal());
00719   }
00720 
00721 //  nlsm.download_prop(SNONLOCAL, alg_stag_non_local_arg->nlocal_buf);
00722   nlsm.download_prop(NLSTAG, (Float *)alg_stag_non_local_arg->nlocal_buf);
00723 
00724   if (aots.last()) {
00725     char *data_file = common_arg->results ? 
00726                       (char *)common_arg->results : CAST_AWAY_CONST("nonlocal.def"); 
00727     FILE *fp;
00728     if( NULL == (fp = Fopen(data_file, "a")) ) {
00729       ERR.FileA(cname,fname, data_file);
00730     }
00731 
00732     write_to_file((Float *)alg_stag_non_local_arg->nlocal_buf, fp, 
00733                   nlsm.propLenTotal(), aots.numSlices(), 1, NLSTAG, nlsm.bcd());
00734     Fclose(fp);
00735 
00736     VRB.Sfree(cname,fname, "alg_stag_non_local_arg->nlocal_buf", 
00737                             (void *)alg_stag_non_local_arg->nlocal_buf);
00738     sfree((void *)alg_stag_non_local_arg->nlocal_buf);
00739     alg_stag_non_local_arg->nlocal_buf = 0;
00740   }
00741 }
00742 
00743 CPS_END_NAMESPACE

Generated on Sat Oct 10 14:11:19 2009 for Columbia Physics System by  doxygen 1.3.9.1