/* ---------------------------------------------------------------------- */IRM_RESULTFileHandler::WriteRestart(int *print_restart)/* ---------------------------------------------------------------------- */{ PhreeqcRM * Reaction_module_ptr = PhreeqcRM::GetInstance(this->rm_id); if (Reaction_module_ptr) { //Reaction_module_ptr->GetSaturation(this->saturation); int mpi_myself = Reaction_module_ptr->GetMpiMyself(); if (print_restart != 0) { gzFile restart_file;#ifdef USE_GZ std::string temp_name("temp_restart_file.gz");#else std::string temp_name("temp_restart_file");#endif std::string name(Reaction_module_ptr->GetFilePrefix()); std::string backup_name(name); if (mpi_myself == 0) {#ifdef USE_GZ name.append(".restart.gz"); backup_name.append(".restart.gz~");#else name.append(".restart"); backup_name.append(".restart~");#endif // open file restart_file = gzopen(temp_name.c_str(), "wb"); if (restart_file == NULL) { std::ostringstream errstr; errstr << "Temporary restart file could not be opened: " << temp_name; error_msg(errstr.str().c_str(), 1); throw PhreeqcRMStop(); } // write header int count_chemistry = Reaction_module_ptr->GetChemistryCellCount(); gzprintf(restart_file, "%s\n", "#PHAST restart file"); gzprintf(restart_file, "%s%s\n", "#Prefix: ", Reaction_module_ptr->GetFilePrefix().c_str()); time_t now = ::time(NULL); gzprintf(restart_file, "%s%s\n", "#Date: ", ctime(&now)); gzprintf(restart_file, "%s%e\n", "#Current model time: ", Reaction_module_ptr->GetTime()); gzprintf(restart_file, "%s%d\n", "#Grid cells: ", Reaction_module_ptr->GetGridCellCount()); gzprintf(restart_file, "%s%d\n", "#Chemistry cells: ", count_chemistry); // write index gzprintf(restart_file, "%d\n", count_chemistry ); for (int j = 0; j < count_chemistry; j++) /* j is count_chem number */ { int i = Reaction_module_ptr->GetBackwardMapping()[j][0]; /* i is nxyz number */ gzprintf(restart_file, "%e %e %e %d ", x_node[i], y_node[i], z_node[i], j); // write all solutions //gzprintf(restart_file, "%d ", this->ic[7 * i]); // solution, use -1 if cell is dry //if (this->saturation[i] > 0.0) //{ // gzprintf(restart_file, "%d ", this->ic[7 * i]); //} //else //{ // gzprintf(restart_file, "-1 "); //} if (this->saturation[i] >= 1.0) { gzprintf(restart_file, "%d ", 1); } else if (this->saturation[i] > 0.0) { gzprintf(restart_file, "%d ", 0); } else { gzprintf(restart_file, "-1 "); } // pp_assemblage gzprintf(restart_file, "%d ", this->ic[7 * i + 1]); // exchange gzprintf(restart_file, "%d ", this->ic[7 * i + 2]); // surface gzprintf(restart_file, "%d ", this->ic[7 * i + 3]); // gas_phase gzprintf(restart_file, "%d ", this->ic[7 * i + 4]); // solid solution gzprintf(restart_file, "%d ", this->ic[7 * i + 5]); // kinetics gzprintf(restart_file, "%d \n", this->ic[7 * i + 6]); } gzclose(restart_file); } // write data Reaction_module_ptr->SetDumpFileName(temp_name.c_str()); Reaction_module_ptr->DumpModule(true, true); // rename files if (mpi_myself == 0) { PhreeqcRM::FileRename(temp_name.c_str(), name.c_str(), backup_name.c_str()); } return IRM_OK; } return IRM_INVALIDARG; } return IRM_BADINSTANCE;}
Line 0: CHEMISTRY_ICLine 1: -box 0.0 0.0 0.0 1000.0 100.0 10.0Line 8: -solid_solutions restart project.restart.gz