int main(int argc, char *argv[]) { PetscErrorCode ierr; MPI_Comm com; PetscMPIInt rank, size; ierr = PetscInitialize(&argc, &argv, PETSC_NULL, help); CHKERRQ(ierr); com = PETSC_COMM_WORLD; ierr = MPI_Comm_rank(com, &rank); CHKERRQ(ierr); ierr = MPI_Comm_size(com, &size); CHKERRQ(ierr); /* This explicit scoping forces destructors to be called before PetscFinalize() */ { ierr = verbosityLevelFromOptions(); CHKERRQ(ierr); ierr = verbPrintf(2,com, "PISMR %s (basic evolution run mode)\n", PISM_Revision); CHKERRQ(ierr); ierr = stop_on_version_option(); CHKERRQ(ierr); ierr = check_old_option_and_stop(com, "-boot_from", "-boot_file"); CHKERRQ(ierr); bool iset, bfset; ierr = PISMOptionsIsSet("-i", iset); CHKERRQ(ierr); ierr = PISMOptionsIsSet("-boot_file", bfset); CHKERRQ(ierr); std::string usage = " pismr {-i IN.nc|-boot_file IN.nc} [OTHER PISM & PETSc OPTIONS]\n" "where:\n" " -i IN.nc is input file in NetCDF format: contains PISM-written model state\n" " -boot_file IN.nc is input file in NetCDF format: contains a few fields, from which\n" " heuristics will build initial model state\n" "notes:\n" " * one of -i or -boot_file is required\n" " * if -boot_file is used then also '-Mx A -My B -Mz C -Lz D' are required\n"; if ((iset == PETSC_FALSE) && (bfset == PETSC_FALSE)) { ierr = PetscPrintf(com, "\nPISM ERROR: one of options -i,-boot_file is required\n\n"); CHKERRQ(ierr); ierr = show_usage_and_quit(com, "pismr", usage); CHKERRQ(ierr); } else { std::vector<std::string> required; required.clear(); ierr = show_usage_check_req_opts(com, "pismr", required, usage.c_str()); CHKERRQ(ierr); } PISMUnitSystem unit_system(NULL); NCConfigVariable config(unit_system), overrides(unit_system); ierr = init_config(com, rank, config, overrides, true); CHKERRQ(ierr); IceGrid g(com, rank, size, config); IceModel m(g, config, overrides); printf("start = %f\n", g.time->start()); printf("end = %f\n", g.time->end()); ierr = m.setExecName("pismr"); CHKERRQ(ierr); ierr = m.init(); CHKERRQ(ierr); //3155692.597470 Natural timestep //m.grid.time->set_end(13155700.0); printf("run_to time = %f\n", g.time->current()); ierr = m.run_to(2e6); CHKERRQ(ierr); printf("run_to time = %f\n", g.time->current()); ierr = m.run_to(1e7); CHKERRQ(ierr); printf("run_to time = %f\n", g.time->current()); ierr = verbPrintf(2,com, "... done with run\n"); CHKERRQ(ierr); // provide a default output file name if no -o option is given. ierr = m.writeFiles("unnamed.nc"); CHKERRQ(ierr); } ierr = PetscFinalize(); CHKERRQ(ierr); return 0; }
QString SettingsManager::getReport() { QString report; QTextStream stream(&report); stream.setFieldAlignment(QTextStream::AlignLeft); stream << QLatin1String("Settings:\n"); QStringList excludeValues; QSettings defaults(QLatin1String(":/schemas/options.ini"), QSettings::IniFormat); const QStringList defaultsGroups = defaults.childGroups(); for (int i = 0; i < defaultsGroups.count(); ++i) { defaults.beginGroup(defaultsGroups.at(i)); const QStringList keys = defaults.childGroups(); for (int j = 0; j < keys.count(); ++j) { const QString type = defaults.value(QStringLiteral("%1/type").arg(keys.at(j))).toString(); if (type == QLatin1String("string") || type == QLatin1String("path")) { excludeValues.append(QStringLiteral("%1/%2").arg(defaultsGroups.at(i)).arg(keys.at(j))); } } defaults.endGroup(); } QHash<QString, int> overridenValues; QSettings overrides(m_overridePath, QSettings::IniFormat); const QStringList overridesGroups = overrides.childGroups(); for (int i = 0; i < overridesGroups.count(); ++i) { overrides.beginGroup(overridesGroups.at(i)); const QStringList keys = overrides.allKeys(); for (int j = 0; j < keys.count(); ++j) { if (overridenValues.contains(keys.at(j))) { ++overridenValues[keys.at(j)]; } else { overridenValues[keys.at(j)] = 1; } } overrides.endGroup(); } QStringList keys = m_defaults.keys(); keys.sort(); for (int i = 0; i < keys.count(); ++i) { stream << QLatin1Char('\t'); stream.setFieldWidth(50); stream << keys.at(i); stream.setFieldWidth(20); if (excludeValues.contains(keys.at(i))) { stream << QLatin1Char('-'); } else { stream << m_defaults[keys.at(i)].toString(); } stream << ((m_defaults[keys.at(i)] == getValue(keys.at(i))) ? QLatin1String("default") : QLatin1String("non default")); stream << (overridenValues.contains(keys.at(i)) ? QStringLiteral("%1 override(s)").arg(overridenValues[keys.at(i)]) : QLatin1String("no overrides")); stream.setFieldWidth(0); stream << QLatin1Char('\n'); } stream << QLatin1Char('\n'); return report; }
QString SettingsManager::getReport() { QString report; QTextStream stream(&report); stream.setFieldAlignment(QTextStream::AlignLeft); stream << QLatin1String("Settings:\n"); QHash<QString, int> overridenValues; QSettings overrides(m_overridePath, QSettings::IniFormat); const QStringList overridesGroups(overrides.childGroups()); for (int i = 0; i < overridesGroups.count(); ++i) { overrides.beginGroup(overridesGroups.at(i)); const QStringList keys(overrides.allKeys()); for (int j = 0; j < keys.count(); ++j) { if (overridenValues.contains(keys.at(j))) { ++overridenValues[keys.at(j)]; } else { overridenValues[keys.at(j)] = 1; } } overrides.endGroup(); } QStringList options; for (int i = 0; i < m_definitions.count(); ++i) { options.append(getOptionName(i)); } options.sort(); for (int i = 0; i < options.count(); ++i) { const OptionDefinition definition(getOptionDefinition(getOptionIdentifier(options.at(i)))); stream << QLatin1Char('\t'); stream.setFieldWidth(50); stream << options.at(i); stream.setFieldWidth(20); if (definition.type == StringType || definition.type == PathType) { stream << QLatin1Char('-'); } else { stream << definition.defaultValue.toString(); } stream << ((definition.defaultValue == getValue(definition.identifier)) ? QLatin1String("default") : QLatin1String("non default")); stream << (overridenValues.contains(options.at(i)) ? QStringLiteral("%1 override(s)").arg(overridenValues[options.at(i)]) : QLatin1String("no overrides")); stream.setFieldWidth(0); stream << QLatin1Char('\n'); } stream << QLatin1Char('\n'); return report; }