#include #include #include #include #include #include using namespace Opm::EclIO; template void write(EclOutput& outFile, EclFile& file1, const std::string& name, int index) { auto vect = file1.get(index); outFile.write(name, vect); } int main(int argc, char **argv) { if (argc != 2) { std::cout << "\nInvalid input, need 1 argument which should be the eclipse output file to be converted \n" << std::endl; exit(1); } // start reading auto start = std::chrono::system_clock::now(); std::string filename = argv[1]; EclFile file1(filename); file1.loadData(); auto end1 = std::chrono::system_clock::now(); std::chrono::duration elapsed_seconds1 = end1 - start; bool formattedOutput = file1.formattedInput() ? false : true; int p = filename.find_last_of("."); int l = filename.length(); std::string rootN = filename.substr(0,p); std::string extension = filename.substr(p,l-p); std::string resFile; if (formattedOutput) { resFile = rootN + ".F" + extension.substr(1, extension.length() - 1); } else { resFile = rootN + "." + extension.substr(2, extension.length() - 2); } std::cout << "\033[1;31m" << "\nconverting " << argv[1] << " -> " << resFile << "\033[0m\n" << std::endl; EclOutput outFile(resFile, formattedOutput); auto arrayList = file1.getList(); for (size_t index = 0; index < arrayList.size(); index++) { std::string name = std::get<0>(arrayList[index]); eclArrType arrType = std::get<1>(arrayList[index]); if (arrType == INTE) { write(outFile, file1, name, index); } else if (arrType == REAL) { write(outFile, file1, name,index); } else if (arrType == DOUB) { write(outFile, file1, name, index); } else if (arrType == LOGI) { write(outFile, file1, name, index); } else if (arrType == CHAR) { write(outFile, file1, name, index); } else if (arrType == MESS) { // shold not be any associated data outFile.write(name,std::vector()); } else { std::cout << "unknown array type " << std::endl; exit(1); } } auto end2 = std::chrono::system_clock::now(); std::chrono::duration elapsed_seconds2 = end2-end1; std::cout << "\ntime to load from file : " << argv[1] << ": " << elapsed_seconds1.count() << " seconds" << std::endl; std::cout << "time to write to file : " << resFile << ": " << elapsed_seconds2.count() << " seconds\n" << std::endl; return 0; }