src/Utility/FieldDebug.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 // FieldDebug.cpp , Tim Williams 10/23/1996
00027 
00028 // include files
00029 #include "Utility/FieldDebug.h"
00030 #include "Utility/FieldDebugPrint.h"
00031 #include "Utility/Inform.h"
00032 #include "Profile/Profiler.h"
00033 #include "Field/BareField.h"
00034 
00035 #ifdef IPPL_USE_STANDARD_HEADERS
00036 #include <iostream>
00037 #include <iomanip> // need format fcns setf() and setprecision() from here
00038 using namespace std;
00039 #else
00040 #include <iostream.h>
00041 #include <iomanip.h> // need format fcns setf() and setprecision() from here
00042 #endif
00043 
00044 
00045 //----------------------------------------------------------------------
00046 // Print a 1D Field
00047 //----------------------------------------------------------------------
00048 template<class T>
00049 void fp1(BareField<T,1U>& field, bool docomm) {
00050   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00051   TAU_PROFILE("fp1()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00052   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00053   int base0   = field.getLayout().getDomain()[0].first();
00054   int bound0  = field.getLayout().getDomain()[0].last();
00055   int stride0 = field.getLayout().getDomain()[0].stride();
00056   sfp1(field, base0, bound0, stride0, docomm);
00057 }
00058 //----------------------------------------------------------------------
00059 // Print a 2D Field
00060 //----------------------------------------------------------------------
00061 template<class T>
00062 void fp2(BareField<T,2U>& field, bool docomm) {
00063   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00064   TAU_PROFILE("fp2()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00065   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00066   int base0   = field.getLayout().getDomain()[0].first();
00067   int bound0  = field.getLayout().getDomain()[0].last();
00068   int stride0 = field.getLayout().getDomain()[0].stride();
00069   int base1   = field.getLayout().getDomain()[1].first();
00070   int bound1  = field.getLayout().getDomain()[1].last();
00071   int stride1 = field.getLayout().getDomain()[1].stride();
00072   sfp2(field, base0, bound0, stride0, base1, bound1, stride1, docomm);
00073 }
00074 //----------------------------------------------------------------------
00075 // Print a 3D Field
00076 //----------------------------------------------------------------------
00077 template<class T>
00078 void fp3(BareField<T,3U>& field, bool docomm) {
00079   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00080   TAU_PROFILE("fp3()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00081   int base0   = field.getLayout().getDomain()[0].first();
00082   int bound0  = field.getLayout().getDomain()[0].last();
00083   int stride0 = field.getLayout().getDomain()[0].stride();
00084   int base1   = field.getLayout().getDomain()[1].first();
00085   int bound1  = field.getLayout().getDomain()[1].last();
00086   int stride1 = field.getLayout().getDomain()[1].stride();
00087   int base2   = field.getLayout().getDomain()[2].first();
00088   int bound2  = field.getLayout().getDomain()[2].last();
00089   int stride2 = field.getLayout().getDomain()[2].stride();
00090   sfp3(field, base0, bound0, stride0, base1, bound1, stride1, 
00091        base2, bound2, stride2, docomm);
00092 }
00093 //----------------------------------------------------------------------
00094 // Print a 1D Field, including global guard layers
00095 //----------------------------------------------------------------------
00096 template<class T>
00097 void ggfp1(BareField<T,1U>& field, bool docomm) {
00098   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00099   TAU_PROFILE("ggfp1()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00100   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00101   int stride0 = field.getLayout().getDomain()[0].stride();
00102   int base0   = field.getLayout().getDomain()[0].first() - 
00103     field.leftGuard(0)*stride0;
00104   int bound0  = field.getLayout().getDomain()[0].last() + 
00105     field.leftGuard(0)*stride0;
00106   sfp1(field, base0, bound0, stride0, docomm);
00107 }
00108 //----------------------------------------------------------------------
00109 // Print a 2D Field, including global guard layers
00110 //----------------------------------------------------------------------
00111 template<class T>
00112 void ggfp2(BareField<T,2U>& field, bool docomm) {
00113   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00114   TAU_PROFILE("ggfp2()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00115   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00116   int stride0 = field.getLayout().getDomain()[0].stride();
00117   int base0   = field.getLayout().getDomain()[0].first() - 
00118     field.leftGuard(0)*stride0;
00119   int bound0  = field.getLayout().getDomain()[0].last() + 
00120     field.leftGuard(0)*stride0;
00121   int stride1 = field.getLayout().getDomain()[1].stride();
00122   int base1   = field.getLayout().getDomain()[1].first() - 
00123     field.leftGuard(1)*stride1;
00124   int bound1  = field.getLayout().getDomain()[1].last() + 
00125     field.leftGuard(1)*stride1;
00126   sfp2(field, base0, bound0, stride0, base1, bound1, stride1, docomm);
00127 }
00128 //----------------------------------------------------------------------
00129 // Print a 3D Field, including global guard layers
00130 //----------------------------------------------------------------------
00131 template<class T>
00132 void ggfp3(BareField<T,3U>& field, bool docomm) {
00133   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00134   TAU_PROFILE("ggfp3()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00135   int stride0 = field.getLayout().getDomain()[0].stride();
00136   int base0   = field.getLayout().getDomain()[0].first() - 
00137     field.leftGuard(0)*stride0;
00138   int bound0  = field.getLayout().getDomain()[0].last() + 
00139     field.leftGuard(0)*stride0;
00140   int stride1 = field.getLayout().getDomain()[1].stride();
00141   int base1   = field.getLayout().getDomain()[1].first() - 
00142     field.leftGuard(1)*stride1;
00143   int bound1  = field.getLayout().getDomain()[1].last() + 
00144     field.leftGuard(1)*stride1;
00145   int stride2 = field.getLayout().getDomain()[2].stride();
00146   int base2   = field.getLayout().getDomain()[2].first() - 
00147     field.leftGuard(2)*stride2;
00148   int bound2  = field.getLayout().getDomain()[2].last() + 
00149     field.leftGuard(2)*stride2;
00150   sfp3(field, base0, bound0, stride0, base1, bound1, stride1, 
00151        base2, bound2, stride2, docomm);
00152 }
00153 //----------------------------------------------------------------------
00154 // Print a 1D Field, including global and internal guard layers
00155 //----------------------------------------------------------------------
00156 template<class T>
00157 void agfp1(BareField<T,1U>& field) {
00158   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00159   TAU_PROFILE("agfp1()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00160   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00161   FieldDebugWriteb(field);
00162 }
00163 //----------------------------------------------------------------------
00164 // Print a 2D Field, including global and internal guard layers
00165 //----------------------------------------------------------------------
00166 template<class T>
00167 void agfp2(BareField<T,2U>& field) {
00168   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00169   TAU_PROFILE("agfp2()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00170   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00171   FieldDebugWriteb(field);
00172 }
00173 //----------------------------------------------------------------------
00174 // Print a 3D Field, including global and internal guard layers
00175 //----------------------------------------------------------------------
00176 template<class T>
00177 void agfp3(BareField<T,3U>& field) {
00178   TAU_TYPE_STRING(taustr, "void (" + CT(field) + " )" );
00179   TAU_PROFILE("agfp3()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00180   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00181   FieldDebugWriteb(field);
00182 }
00183 //----------------------------------------------------------------------
00184 // Print a single element of a 1D Field
00185 //----------------------------------------------------------------------
00186 template<class T>
00187 void efp1(BareField<T,1U>& field, int i, bool docomm) {
00188   TAU_TYPE_STRING(taustr, "void (" + CT(field) + ", int )" );
00189   TAU_PROFILE("efp1()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00190   sfp1(field, i, i, 1, docomm);
00191 }
00192 //----------------------------------------------------------------------
00193 // Print a single element of a 2D Field
00194 //----------------------------------------------------------------------
00195 template<class T>
00196 void efp2(BareField<T,2U>& field, int i, int j, bool docomm) {
00197   TAU_TYPE_STRING(taustr, "void (" + CT(field) + ", int, int )" );
00198   TAU_PROFILE("efp2()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00199   sfp2(field, i, i, 1, j, j, 1, docomm);
00200 }
00201 //----------------------------------------------------------------------
00202 // Print a single element of a 3D Field
00203 //----------------------------------------------------------------------
00204 template<class T>
00205 void efp3(BareField<T,3U>& field, int i, int j, int k, bool docomm) {
00206   TAU_TYPE_STRING(taustr, "void (" + CT(field) + ", int, int, int )" );
00207   TAU_PROFILE("efp3()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00208   sfp3(field, i, i, 1, j, j, 1, k, k, 1, docomm);
00209 }
00210 //----------------------------------------------------------------------
00211 // Print a strided slice (range) of a 1D Field
00212 //----------------------------------------------------------------------
00213 template<class T>
00214 void sfp1(BareField<T,1U>& field,
00215           int ibase, int ibound, int istride, bool docomm) {
00216   TAU_TYPE_STRING(taustr, "void (" + CT(field) + ", int, int, int )" );
00217   TAU_PROFILE("sfp1()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00218 
00219   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00220 
00221   // Check input parameters for errors and unimplemented values:
00222   bool okParameters = true;
00223   int first0 = field.getLayout().getDomain()[0].first() - 
00224     field.leftGuard(0) * field.getDomain()[0].stride();
00225   int last0 = field.getLayout().getDomain()[0].last() + field.leftGuard(0);
00226   if (ibase < first0) {
00227     (*FldDbgInform) << "sfp() error: ibase (= " << ibase
00228                     << ") < lowest index value (= " << first0 << ")" << endl;
00229     okParameters = false;
00230   }
00231   if (ibound > last0) {
00232     (*FldDbgInform) << "sfp() error: ibound (= " << ibound 
00233                     << ") > highest index value (= " << last0 << ")" << endl;
00234     okParameters = false;
00235   }
00236   if (istride < 0) {
00237     (*FldDbgInform) << "sfp() error: istride < 0 not implemented yet." << endl;
00238     okParameters = false;
00239   } else {
00240     if (ibound < ibase) {
00241       (*FldDbgInform) << "sfp() error: ibase (= " << ibase
00242                       << ") > ibound (=  " << ibound << ") not implemented yet." << endl;
00243       okParameters = false;
00244     }
00245   }
00246   if (istride == 0) {
00247     if ( (ibound - ibase) != 0 ) {
00248       (*FldDbgInform) << "sfp() error: istride = 0 but (ibound - ibase) = " 
00249                       << (ibound - ibase) << endl;
00250       okParameters = false;
00251     } else {
00252       istride = 1; // Allow specifying stride 0 for 1-element range; set=1 
00253     }
00254   }
00255 
00256   if (okParameters) {
00257     NDIndex<1U> ndi(Index(ibase,ibound,istride));
00258     FieldDebugPrint<T,1U> dfp(true,widthOfElements,digitsPastDecimal,
00259                               elementsPerLine);
00260     dfp.print(field, ndi, *FldDbgInform, docomm);
00261   }
00262 }
00263 //----------------------------------------------------------------------
00264 // Print a strided slice (range) of a 2D Field
00265 //----------------------------------------------------------------------
00266 template<class T>
00267 void sfp2(BareField<T,2U>& field,
00268           int ibase, int ibound, int istride,
00269           int jbase, int jbound, int jstride, bool docomm) {
00270   TAU_TYPE_STRING(taustr, "void (" + CT(field) 
00271     + ", int, int, int, int, int, int )" );
00272   TAU_PROFILE("sfp2()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00273 
00274   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00275 
00276   // Check input parameters for errors and unimplemented values:
00277   bool okParameters = true;
00278   int first0 = field.getLayout().getDomain()[0].first() - 
00279     field.leftGuard(0) * field.getDomain()[0].stride();
00280   int last0 = field.getLayout().getDomain()[0].last() + field.leftGuard(0);
00281   if (ibase < first0) {
00282     (*FldDbgInform) << "sfp() error: ibase (= " << ibase
00283                     << ") < lowest index value (= " << first0 << ")" << endl;
00284     okParameters = false;
00285   }
00286   if (ibound > last0) {
00287     (*FldDbgInform) << "sfp() error: ibound (= " << ibound 
00288                     << ") > highest index value (= " << last0 << ")" << endl;
00289     okParameters = false;
00290   }
00291   if (istride < 0) {
00292     (*FldDbgInform) << "sfp() error: istride < 0 not implemented yet." << endl;
00293     okParameters = false;
00294   } else {
00295     if (ibound < ibase) {
00296       (*FldDbgInform) << "sfp() error: ibase (= " << ibase
00297                       << ") > ibound (=  " << ibound << ") not implemented yet." << endl;
00298       okParameters = false;
00299     }
00300   }
00301   if (istride == 0) {
00302     if ( (ibound - ibase) != 0 ) {
00303       (*FldDbgInform) << "sfp() error: istride = 0 but (ibound - ibase) = " 
00304                       << (ibound - ibase) << endl;
00305       okParameters = false;
00306     } else {
00307       istride = 1; // Allow specifying stride 0 for 1-element range; set=1 
00308     }
00309   }
00310   int first1 = field.getLayout().getDomain()[1].first() - 
00311     field.leftGuard(1) * field.getDomain()[1].stride();
00312   int last1 = field.getLayout().getDomain()[1].last() + field.leftGuard(1);
00313   if (jbase < first1) {
00314     (*FldDbgInform) << "sfp() error: jbase (= " << jbase
00315                     << ") < lowest index value (= " << first1 << ")" << endl;
00316     okParameters = false;
00317   }
00318   if (jbound > last1) {
00319     (*FldDbgInform) << "sfp() error: jbound (= " << jbound 
00320                     << ") > highest index value (= " << last1 << ")" << endl;
00321     okParameters = false;
00322   }
00323   if (jstride < 0) {
00324     (*FldDbgInform) << "sfp() error: jstride < 0 not implemented yet." << endl;
00325     okParameters = false;
00326   } else {
00327     if (jbound < jbase) {
00328       (*FldDbgInform) << "sfp() error: jbase (= " << jbase
00329                       << ") > jbound (=  " << jbound << ") not implemented yet." << endl;
00330       okParameters = false;
00331     }
00332   }
00333   if (jstride == 0) {
00334     if ( (jbound - jbase) != 0 ) {
00335       (*FldDbgInform) << "sfp() error: jstride = 0 but (jbound - jbase) = " 
00336                       << (jbound - jbase) << endl;
00337       okParameters = false;
00338     } else {
00339       jstride = 1; // Allow specifying stride 0 for 1-element range; set=1 
00340     }
00341   }
00342 
00343   if (okParameters) {
00344     NDIndex<2U> ndi(Index(ibase,ibound,istride),Index(jbase,jbound,jstride));
00345     FieldDebugPrint<T,2U> dfp(true,widthOfElements,digitsPastDecimal,
00346                               elementsPerLine);
00347     dfp.print(field, ndi, *FldDbgInform, docomm);
00348   }
00349 }
00350 //----------------------------------------------------------------------
00351 // Print a strided slice (range) of a 3D Field
00352 //----------------------------------------------------------------------
00353 template<class T>
00354 void sfp3(BareField<T,3U>& field,
00355           int ibase, int ibound, int istride,
00356           int jbase, int jbound, int jstride,
00357           int kbase, int kbound, int kstride, bool docomm) {
00358   TAU_TYPE_STRING(taustr, "void (" + CT(field) 
00359     + ", int, int, int, int, int, int, int, int, int )" );
00360   TAU_PROFILE("sfp3()", taustr, TAU_UTILITY | TAU_FIELD | TAU_IO);
00361 
00362   if (!FldDbgInformIsSet) setInform(*IpplInfo::Info); // Set ptr if not set.
00363 
00364   // Check input parameters for errors and unimplemented values:
00365   bool okParameters = true;
00366   int first0 = field.getLayout().getDomain()[0].first() - 
00367     field.leftGuard(0) * field.getDomain()[0].stride();
00368   int last0 = field.getLayout().getDomain()[0].last() + field.leftGuard(0);
00369   if (ibase < first0) {
00370     (*FldDbgInform) << "sfp() error: ibase (= " << ibase
00371                     << ") < lowest index value (= " << first0 << ")" << endl;
00372     okParameters = false;
00373   }
00374   if (ibound > last0) {
00375     (*FldDbgInform) << "sfp() error: ibound (= " << ibound 
00376                     << ") > highest index value (= " << last0 << ")" << endl;
00377     okParameters = false;
00378   }
00379   if (istride < 0) {
00380     (*FldDbgInform) << "sfp() error: istride < 0 not implemented yet." << endl;
00381     okParameters = false;
00382   } else {
00383     if (ibound < ibase) {
00384       (*FldDbgInform) << "sfp() error: ibase (= " << ibase
00385                       << ") > ibound (=  " << ibound << ") not implemented yet." << endl;
00386       okParameters = false;
00387     }
00388   }
00389   if (istride == 0) {
00390     if ( (ibound - ibase) != 0 ) {
00391       (*FldDbgInform) << "sfp() error: istride = 0 but (ibound - ibase) = " 
00392                       << (ibound - ibase) << endl;
00393       okParameters = false;
00394     } else {
00395       istride = 1; // Allow specifying stride 0 for 1-element range; set=1 
00396     }
00397   }
00398   int first1 = field.getLayout().getDomain()[1].first() - 
00399     field.leftGuard(1) * field.getDomain()[1].stride();
00400   int last1 = field.getLayout().getDomain()[1].last() + field.leftGuard(1);
00401   if (jbase < first1) {
00402     (*FldDbgInform) << "sfp() error: jbase (= " << jbase
00403                     << ") < lowest index value (= " << first1 << ")" << endl;
00404     okParameters = false;
00405   }
00406   if (jbound > last1) {
00407     (*FldDbgInform) << "sfp() error: jbound (= " << jbound 
00408                     << ") > highest index value (= " << last1 << ")" << endl;
00409     okParameters = false;
00410   }
00411   if (jstride < 0) {
00412     (*FldDbgInform) << "sfp() error: jstride < 0 not implemented yet." << endl;
00413     okParameters = false;
00414   } else {
00415     if (jbound < jbase) {
00416       (*FldDbgInform) << "sfp() error: jbase (= " << jbase
00417                       << ") > jbound (=  " << jbound << ") not implemented yet." << endl;
00418       okParameters = false;
00419     }
00420   }
00421   if (jstride == 0) {
00422     if ( (jbound - jbase) != 0 ) {
00423       (*FldDbgInform) << "sfp() error: jstride = 0 but (jbound - jbase) = " 
00424                       << (jbound - jbase) << endl;
00425       okParameters = false;
00426     } else {
00427       jstride = 1; // Allow specifying stride 0 for 1-element range; set=1 
00428     }
00429   }
00430   int first2 = field.getLayout().getDomain()[2].first() - 
00431     field.leftGuard(2) * field.getDomain()[2].stride();
00432   int last2 = field.getLayout().getDomain()[2].last() + field.leftGuard(2);
00433   if (kbase < first2) {
00434     (*FldDbgInform) << "sfp() error: kbase (= " << kbase
00435                     << ") < lowest index value (= " << first2 << ")" << endl;
00436     okParameters = false;
00437   }
00438   if (kbound > last2) {
00439     (*FldDbgInform) << "sfp() error: kbound (= " << kbound 
00440                     << ") > highest index value (= " << last2 << ")" << endl;
00441     okParameters = false;
00442   }
00443   if (kstride < 0) {
00444     (*FldDbgInform) << "sfp() error: kstride < 0 not implemented yet." << endl;
00445     okParameters = false;
00446   } else {
00447     if (kbound < kbase) {
00448       (*FldDbgInform) << "sfp() error: kbase (= " << kbase
00449                       << ") > kbound (=  " << jbound << ") not implemented yet." << endl;
00450       okParameters = false;
00451     }
00452   }
00453   if (kstride == 0) {
00454     if ( (kbound - kbase) != 0 ) {
00455       (*FldDbgInform) << "sfp() error: kstride = 0 but (kbound - kbase) = " 
00456                       << (kbound - kbase) << endl;
00457       okParameters = false;
00458     } else {
00459       kstride = 1; // Allow specifying stride 0 for 1-element range; set=1 
00460     }
00461   }
00462 
00463   if (okParameters) {
00464     NDIndex<3U> ndi(Index(ibase,ibound,istride),Index(jbase,jbound,jstride),
00465                     Index(kbase,kbound,kstride));
00466     FieldDebugPrint<T,3U> dfp(true,widthOfElements,digitsPastDecimal,
00467                               elementsPerLine);
00468     dfp.print(field, ndi, *FldDbgInform, docomm);
00469   }
00470 }
00471 
00472 //----------------------------------------------------------------------
00473 // An output function which writes out a BareField a vnode at a time and
00474 // includes the border information, using fp[1,2,3]-like formatting as much as
00475 // possible. Patterned after BareField::writeb()
00476 //----------------------------------------------------------------------
00477 
00478 template< class T, unsigned Dim >
00479 void FieldDebugWriteb(BareField<T,Dim>& F)
00480 {
00481   TAU_TYPE_STRING(taustr, CT(*this) + " void (char * )" );
00482   TAU_PROFILE("FieldDebugWriteb", taustr, TAU_FIELD | TAU_IO);
00483 
00484   int ibase,ibound,istride,jbase,jbound,jstride,kbase,kbound,kstride;
00485   istride = F.getLayout().getDomain()[0].stride();
00486   ibase   = F.getLayout().getDomain()[0].first() - F.leftGuard(0)*istride;
00487   ibound  = F.getLayout().getDomain()[0].last() + F.leftGuard(0)*istride;
00488   if (Dim >= 2) {
00489     jstride = F.getLayout().getDomain()[1].stride();
00490     jbase   = F.getLayout().getDomain()[1].first() - F.leftGuard(1)*jstride;
00491     jbound  = F.getLayout().getDomain()[1].last() + F.leftGuard(1)*jstride;
00492   }
00493   if (Dim >= 3) {
00494     kstride = F.getLayout().getDomain()[2].stride();
00495     kbase   = F.getLayout().getDomain()[2].first() - F.leftGuard(2)*kstride;
00496     kbound  = F.getLayout().getDomain()[2].last() + F.leftGuard(2)*kstride;
00497   }
00498   (*FldDbgInform) << "~~~~~~~~ field slice ("
00499                   << ibase << ":" << ibound << ":" << istride <<  ", "
00500                   << jbase << ":" << jbound << ":" << jstride <<  ", "
00501                   << kbase << ":" << kbound << ":" << kstride <<  ") "
00502                   << "~~~~~~~~" << endl;
00503   int icount = 0;
00504   int iBlock;
00505   typename BareField<T,Dim>::const_iterator_if l_i;
00506   for (l_i = F.begin_if(); l_i != F.end_if(); ++l_i) {
00507     // find the offset within the global space
00508     LField<T,Dim> *ldf = (*l_i).second.get();
00509     const NDIndex<Dim> &Owned = ldf->getOwned();
00510 
00511     (*FldDbgInform) << "****************************************"
00512                     << "***************************************" << endl;
00513     (*FldDbgInform) << "********* vnode = " << icount++ << " *********" 
00514                     << endl;
00515     (*FldDbgInform) << "****************************************"
00516                     << "***************************************" << endl;
00517     cout << "Owned = " << endl << Owned << endl;
00518     typename LField<T,Dim>::iterator lf_bi = ldf->begin();
00519     if ( Dim==1 ) {
00520       int n0 = ldf->size(0);
00521       int l0 = -F.leftGuard(0);   // tjw: assumes stride 1, right???
00522       int r0 = n0 + F.rightGuard(0);
00523       int ifirst = Owned[0].first() - F.leftGuard(0)*istride;
00524       int ilast = Owned[0].last() + F.rightGuard(0);
00525       (*FldDbgInform) << "- - - - - - - - - - - - - - - - - - - - - - - - - "
00526                       << "I = " << ifirst << ":" << ilast << ":"
00527                       << istride << endl;
00528       for ( iBlock = l0 ; iBlock < r0 ; iBlock += elementsPerLine) {
00529         for (int i0=iBlock; 
00530              ((i0 < iBlock + elementsPerLine*istride) && (i0 < r0)); 
00531              i0 = i0 + istride) {
00532           (*FldDbgInform) << setprecision(digitsPastDecimal) 
00533                           << setw(widthOfElements)
00534                           << lf_bi.offset(i0) << " ";
00535         }
00536         (*FldDbgInform) << endl;
00537       }
00538     } else if ( Dim==2 ) {
00539       int n0 = ldf->size(0);
00540       int n1 = ldf->size(1);
00541       int l0 = -F.leftGuard(0);
00542       int l1 = -F.leftGuard(1);
00543       int r0 = n0 + F.rightGuard(0);
00544       int r1 = n1 + F.rightGuard(1);
00545       int j = 0;
00546       int ifirst = Owned[0].first() - F.leftGuard(0)*istride;
00547       int ilast = Owned[0].last() + F.rightGuard(0);
00548       int jfirst = Owned[1].first();
00549       // (re)define jbase, jbound, jlast w/o guards
00550       int jlast = Owned[1].last();
00551       jbase = F.getLayout().getDomain()[1].first();
00552       jbound  = F.getLayout().getDomain()[1].last();
00553       for (int i1=l1; i1<r1; ++i1) {
00554         j = jfirst + i1;
00555         if ((j < jfirst) || (j > jlast)) {
00556           if ((j < jbase) || (j > jbound)) {
00557             (*FldDbgInform) 
00558               << "--------------------------------global guard------";
00559           } else {
00560             (*FldDbgInform) 
00561               << "---------------------------------------guard------";
00562           }
00563         } else {
00564           (*FldDbgInform) 
00565             << "--------------------------------------------------";
00566         }
00567         (*FldDbgInform) << "- - - - - - - - - - - - - - - - - - - - - - - - - "
00568                         << "I = " << ifirst << ":" << ilast << ":" 
00569                         << istride << endl;
00570         for ( iBlock = l0 ; iBlock < r0 ; iBlock += elementsPerLine) {
00571           for (int i0=iBlock; 
00572                ((i0 < iBlock + elementsPerLine*istride) && (i0 < r0)); 
00573                i0 = i0 + istride) {
00574             (*FldDbgInform) << setprecision(digitsPastDecimal) 
00575                             << setw(widthOfElements)
00576                             << lf_bi.offset(i0,i1) << " ";
00577           }
00578           (*FldDbgInform) << endl;
00579         }
00580         (*FldDbgInform) << endl;
00581       }
00582     } else if ( Dim==3 ) {
00583       int n0 = ldf->size(0);
00584       int n1 = ldf->size(1);
00585       int n2 = ldf->size(2);
00586       int l0 = -F.leftGuard(0);
00587       int l1 = -F.leftGuard(1);
00588       int l2 = -F.leftGuard(2);
00589       int r0 = n0 + F.rightGuard(0);
00590       int r1 = n1 + F.rightGuard(1);
00591       int r2 = n2 + F.rightGuard(2);
00592       int j = 0;
00593       int k = 0;
00594       int ifirst = Owned[0].first() - F.leftGuard(0)*istride;
00595       int ilast = Owned[0].last() + F.rightGuard(0);
00596       int jfirst = Owned[1].first();
00597       // (re)define jbase, jbound, jlast w/o guards
00598       int jlast = Owned[1].last();
00599       jbase = F.getLayout().getDomain()[1].first();
00600       jbound  = F.getLayout().getDomain()[1].last();
00601       int kfirst = Owned[2].first();
00602       // (re)define kbase, kbound, klast w/o guards
00603       int klast = Owned[2].last();
00604       kbase = F.getLayout().getDomain()[2].first();
00605       kbound  = F.getLayout().getDomain()[2].last();
00606       for (int i2=l2; i2<r2; ++i2) {
00607         k = kfirst + i2;
00608         if ((k < kfirst) || (k > klast)) {
00609           if ((k < kbase) || (k > kbound)) {
00610             (*FldDbgInform) 
00611               << "================================global guard======";
00612           } else {
00613             (*FldDbgInform) 
00614               << "=======================================guard======";
00615           }
00616         } else {
00617           (*FldDbgInform) 
00618             << "==================================================";
00619         }
00620         (*FldDbgInform) << "K = " << k << endl;
00621         for (int i1=l1; i1<r1; ++i1) {
00622           j = jfirst + i1;
00623           if ((j < jfirst) || (j > jlast)) {
00624             if ((j < jbase) || (j > jbound)) {
00625               (*FldDbgInform) 
00626                 << "--------------------------------global guard------";
00627             } else {
00628               (*FldDbgInform) 
00629                 << "---------------------------------------guard------";
00630             }
00631           } else {
00632             (*FldDbgInform) 
00633               << "--------------------------------------------------";
00634           }
00635           (*FldDbgInform) << "J = " << j << endl;
00636           (*FldDbgInform) 
00637             << "- - - - - - - - - - - - - - - - - - - - - - - - - "
00638             << "I = " << ifirst << ":" << ilast << ":" << istride << endl;
00639           for ( iBlock = l0 ; iBlock < r0 ; iBlock += elementsPerLine) {
00640             for (int i0=iBlock; 
00641                  ((i0 < iBlock + elementsPerLine*istride) && (i0 < r0)); 
00642                  i0 = i0 + istride) {
00643               (*FldDbgInform) << setprecision(digitsPastDecimal) 
00644                               << setw(widthOfElements)
00645                               << lf_bi.offset(i0,i1,i2) << " ";
00646             }
00647             (*FldDbgInform) << endl;
00648           }
00649           (*FldDbgInform) << endl;
00650         }
00651         (*FldDbgInform) << endl;
00652       }
00653     } else {
00654       ERRORMSG(" can not write for larger than three dimensions " << endl);
00655     }
00656   }
00657 }
00658 
00659 
00660 /***************************************************************************
00661  * $RCSfile: FieldDebug.cpp,v $   $Author: adelmann $
00662  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:33 $
00663  * IPPL_VERSION_ID: $Id: FieldDebug.cpp,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $ 
00664  ***************************************************************************/

Generated on Mon Jan 16 13:23:58 2006 for IPPL by  doxygen 1.4.6