| 70 | |
| 71 | |
| 72 | int main(int argc, char* argv[]) |
| 73 | { |
| 74 | amrex::Initialize(argc, argv); |
| 75 | { |
| 76 | if(argc == 1) |
| 77 | PrintUsage(argv[0]); |
| 78 | |
| 79 | if (ParallelDescriptor::NProcs() > 1){ |
| 80 | amrex::Error("This is an inherently serial program!"); |
| 81 | } |
| 82 | ParmParse pp; |
| 83 | |
| 84 | std::string name; |
| 85 | pp.get("infile", name); |
| 86 | |
| 87 | // |
| 88 | // MatLab expects native floating-point format. |
| 89 | // |
| 90 | FArrayBox::setFormat(FABio::FAB_NATIVE); |
| 91 | |
| 92 | VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size); |
| 93 | char buf[128]; |
| 94 | std::string file = name; |
| 95 | file += ".mat"; |
| 96 | std::ofstream os; |
| 97 | |
| 98 | os.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size()); |
| 99 | |
| 100 | os.open(file.c_str(), std::ios::out|std::ios::binary); |
| 101 | |
| 102 | if(os.fail()) { |
| 103 | amrex::FileOpenFailed(file); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | MultiFab in; |
| 108 | VisMF::Read(in, name); |
| 109 | const BoxArray ba = in.boxArray(); |
| 110 | |
| 111 | //Fake a xlo to xhi |
| 112 | for(int i = 0; i < ba.size(); ++i) |
| 113 | { |
| 114 | const Box& b = ba[i]; |
| 115 | Real xlo[BL_SPACEDIM], xhi[BL_SPACEDIM]; |
| 116 | for(int d = 0; d <BL_SPACEDIM; ++d) |
| 117 | { |
| 118 | xlo[d] = b.loVect()[d]; |
| 119 | xhi[d] = b.hiVect()[d]; |
| 120 | os.write((char*)&xlo,sizeof(Real)); |
| 121 | os.write((char*)&xhi,sizeof(Real)); |
| 122 | } |
| 123 | } |
| 124 | //Write the Fab Data |
| 125 | for(int i = 0; i < ba.size(); ++i) |
| 126 | { |
| 127 | WriteFab(os, in[i], buf); |
| 128 | } |
| 129 | os.close(); |
nothing calls this directly
no test coverage detected