#include "agn.hpp" #include "spectral_lines.hpp" int main(int argc, char const *argv[]) { std::ifstream cloudy_result_file; cloudy_result_file.open(argv[1]); std::cout << "Reading cloudy grid from " << argv[1] << ".\n"; agn::cloudy_grid grid = agn::read_cloudy_grid(cloudy_result_file); std::cout << "Reading line list from " << argv[2] << ".\n"; std::ifstream line_list_file; line_list_file.open(argv[2]); agn::line_list lines_to_print = agn::read_line_list(line_list_file); std::cout << "Compiling table2ds for " << lines_to_print.size() << " emission lines.\n"; std::list tables = agn::compile_eqwidth_tables(grid,lines_to_print,1215.00); std::cout << "Printing " << tables.size() << " tables to fortfiles.\n"; std::list::iterator table_it = tables.begin(); int fortfilenum=11; while(table_it != tables.end()) { std::ofstream outfile; std::stringstream filename; filename << "fort."; filename << fortfilenum; outfile.open(filename.str().c_str()); outfile << *table_it; outfile.close(); table_it++; fortfilenum++; } int num_unconverged = 0; agn::cloudy_grid::iterator result_it = grid.begin(); std::ofstream cautionreportfile; cautionreportfile.open("cautions"); cautionreportfile << "The following solutions probably did not converge." << std::endl << std::endl; while(result_it != grid.end()) { if (result_it->second.iterations >= 40) { num_unconverged++; cautionreportfile << "hden = " << std::fixed << std::setprecision(3) << result_it->second.hden << ", phi = " << result_it->second.phi << std::endl << "───────────────────────────" << std::endl; std::list::iterator caution_it = result_it->second.cautions.begin(); while(caution_it != result_it->second.cautions.end()) { cautionreportfile << *caution_it << std::endl; caution_it++; } cautionreportfile << std::endl << std::endl; } result_it++; } std::cout << "Saved cautions for " << num_unconverged << " unconverged solutions." << std::endl; cautionreportfile.close(); std::cout << "Done.\n"; return 0; }