+ MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);
+ MPI_File_get_size(inMPI, &size);
+ //delete inFileName;
+
+
+ char* buffer = new char[size];
+ MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
+
+ string tempBuf = buffer;
+ if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size); }
+ istringstream iss (tempBuf,istringstream::in);
+ delete buffer;
+
+ //read version
+ string line = m->getline(iss); m->gobble(iss);
+
+ while(!iss.eof()) {
+ iss >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine;
+
+ temp.clear();
+
+ temp.push_back(ten);
+ temp.push_back(twentyfive);
+ temp.push_back(fifty);
+ temp.push_back(seventyfive);
+ temp.push_back(ninetyfive);
+ temp.push_back(ninetynine);
+
+ quan.push_back(temp);
+
+ m->gobble(iss);
+ }
+
+ MPI_File_close(&inMPI);
+
+ #else
+
+ ifstream in;
+ m->openInputFile(quanfile, in);
+
+ //read version
+ string line = m->getline(in); m->gobble(in);
+
+ while(!in.eof()){
+
+ in >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine;
+
+ temp.clear();
+
+ temp.push_back(ten);
+ temp.push_back(twentyfive);
+ temp.push_back(fifty);
+ temp.push_back(seventyfive);
+ temp.push_back(ninetyfive);
+ temp.push_back(ninetynine);
+
+ quan.push_back(temp);
+
+ m->gobble(in);
+ }
+ in.close();
+ #endif
+
+ return quan;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Pintail", "readQuantiles");
+ exit(1);
+ }
+}
+//***************************************************************************************************************/
+
+void Pintail::printQuanFile(string file, string outputString) {
+ try {
+
+ #ifdef USE_MPI
+
+ MPI_File outQuan;
+ MPI_Status status;
+
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
+
+ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY;
+
+ //char* FileName = new char[file.length()];
+ //memcpy(FileName, file.c_str(), file.length());
+
+ char FileName[1024];
+ strcpy(FileName, file.c_str());
+
+ if (pid == 0) {
+ MPI_File_open(MPI_COMM_SELF, FileName, outMode, MPI_INFO_NULL, &outQuan); //comm, filename, mode, info, filepointer
+
+ int length = outputString.length();
+ char* buf = new char[length];
+ memcpy(buf, outputString.c_str(), length);
+
+ MPI_File_write(outQuan, buf, length, MPI_CHAR, &status);
+ delete buf;
+
+ MPI_File_close(&outQuan);
+ }
+
+ //delete FileName;
+ #else
+ ofstream outQuan;
+ m->openOutputFile(file, outQuan);
+
+ outQuan << outputString;
+
+ outQuan.close();
+ #endif
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Pintail", "printQuanFile");
+ exit(1);
+ }
+}
+
+//***************************************************************************************************************/