Esempio n. 1
0
void scandepot(void) {
    DIR *depot;
    struct dirent *de;
    struct partqueue *pq;
    char *p;

    assert(!queue);
    depot = opendir(opt_depotdir);
    if (!depot)
        ohshite(_("unable to read depot directory `%.250s'"), opt_depotdir);
    while ((de= readdir(depot))) {
        if (de->d_name[0] == '.') continue;
        pq= nfmalloc(sizeof(struct partqueue));
        pq->info.fmtversion= pq->info.package= pq->info.version= NULL;
        pq->info.orglength= pq->info.thispartoffset= pq->info.thispartlen= 0;
        pq->info.headerlen= 0;
        p = nfmalloc(strlen(opt_depotdir) + strlen(de->d_name) + 1);
        strcpy(p, opt_depotdir);
        strcat(p,de->d_name);
        pq->info.filename= p;
        if (!decompose_filename(de->d_name,pq)) {
            pq->info.md5sum= NULL;
            pq->info.maxpartlen= pq->info.thispartn= pq->info.maxpartn= 0;
        }
        pq->nextinqueue= queue;
        queue= pq;
    }
    closedir(depot);
}
Esempio n. 2
0
bool Excn::SystemInterface::parse_options(int argc, char **argv)
{
  // Get options from environment variable also...
  char *options = getenv("EPU_OPTIONS");
  if (options != nullptr) {
    std::cout
        << "\nThe following options were specified via the EPU_OPTIONS environment variable:\n"
        << "\t" << options << "\n\n";
    options_.parse(options, options_.basename(*argv));
  }

  int option_index = options_.parse(argc, argv);
  if (option_index < 1)
    return false;

  if (options_.retrieve("help")) {
    options_.usage();
    std::cout << "\n\tCan also set options via EPU_OPTIONS environment variable.\n\n"
              << "\tWrites: current_directory/basename.suf\n"
              << "\tReads:  root#o/sub/basename.suf.#p.0 to\n"
              << "\t\troot(#o+#p)%#r/sub/basename.suf.#p.#p\n";
    std::cout << "\n\t->->-> Send email to [email protected] for epu support.<-<-<-\n";
    exit(EXIT_SUCCESS);
  }

  if (options_.retrieve("version")) {
    // Version is printed up front, just exit...
    exit(0);
  }

  {
    const char *temp = options_.retrieve("extension");
    if (temp != nullptr) {
      inExtension_ = temp;
    }
  }

  {
    const char *temp = options_.retrieve("output_extension");
    if (temp != nullptr) {
      outExtension_ = temp;
    }
  }

  {
    const char *temp = options_.retrieve("offset");
    if (temp != nullptr) {
      raidOffset_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("raid_count");
    if (temp != nullptr) {
      raidCount_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("processor_count");
    if (temp != nullptr) {
      processorCount_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("Part_count");
    if (temp != nullptr) {
      partCount_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("start_part");
    if (temp != nullptr) {
      startPart_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("current_directory");
    if (temp != nullptr) {
      cwd_ = temp;
    }
  }

  {
    const char *temp = options_.retrieve("Root_directory");
    if (temp != nullptr) {
      rootDirectory_ = temp;
    }
  }

  {
    const char *temp = options_.retrieve("Subdirectory");
    if (temp != nullptr) {
      subDirectory_ = temp;
    }
  }

  {
    const char *temp = options_.retrieve("debug");
    if (temp != nullptr) {
      debugLevel_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("width");
    if (temp != nullptr) {
      screenWidth_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("steps");
    if (temp != nullptr) {
      parse_step_option(temp);
    }
  }

  {
    const char *temp = options_.retrieve("gvar");
    parse_variable_names(temp, &globalVarNames_);
  }

  {
    const char *temp = options_.retrieve("nvar");
    parse_variable_names(temp, &nodeVarNames_);
  }

  {
    const char *temp = options_.retrieve("evar");
    parse_variable_names(temp, &elemVarNames_);
  }

  {
    const char *temp = options_.retrieve("nsetvar");
    parse_variable_names(temp, &nsetVarNames_);
  }

  {
    const char *temp = options_.retrieve("ssetvar");
    parse_variable_names(temp, &ssetVarNames_);
  }

  if (options_.retrieve("add_processor_id")) {
    addProcessorId_ = true;
  }
  else {
    addProcessorId_ = false;
  }

  if (options_.retrieve("large_model")) {
    useNetcdf4_ = true;
    std::cerr << "\nWARNING: the -large_model option is deprecated; please use -netcdf4 instead.\n";
  }

  if (options_.retrieve("netcdf4")) {
    useNetcdf4_ = true;
  }

  if (options_.retrieve("append")) {
    append_ = true;
  }

  if (options_.retrieve("64")) {
    intIs64Bit_ = true;
  }

  {
    const char *temp = options_.retrieve("compress_data");
    if (temp != nullptr) {
      compressData_ = strtol(temp, nullptr, 10);
    }
  }

  if (options_.retrieve("sum_shared_nodes")) {
    sumSharedNodes_ = true;
  }

  if (options_.retrieve("append")) {
    append_ = true;
  }

  {
    const char *temp = options_.retrieve("subcycle");
    if (temp != nullptr) {
      subcycle_ = strtol(temp, nullptr, 10);
    }
  }

  {
    const char *temp = options_.retrieve("cycle");
    if (temp != nullptr) {
      cycle_ = strtol(temp, nullptr, 10);
    }
  }

  if (options_.retrieve("join_subcycles")) {
    subcycleJoin_ = true;
  }

  if (options_.retrieve("map")) {
    mapIds_ = true;
  }

  if (options_.retrieve("nomap")) {
    mapIds_ = false;
  }

  if (options_.retrieve("omit_nodesets")) {
    omitNodesets_ = true;
  }
  else {
    omitNodesets_ = false;
  }

  if (options_.retrieve("omit_sidesets")) {
    omitSidesets_ = true;
  }
  else {
    omitSidesets_ = false;
  }

  if (options_.retrieve("output_shared_nodes")) {
    outputSharedNodes_ = true;
  }

  if (options_.retrieve("copyright")) {
    std::cout << "\n"
              << "Copyright(C) 2010 Sandia Corporation.  Under the terms of Contract\n"
              << "DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains\n"
              << "certain rights in this software\n"
              << "\n"
              << "Redistribution and use in source and binary forms, with or without\n"
              << "modification, are permitted provided that the following conditions are\n"
              << "met:\n"
              << "\n"
              << "    * Redistributions of source code must retain the above copyright\n"
              << "      notice, this list of conditions and the following disclaimer.\n"
              << "\n"
              << "    * Redistributions in binary form must reproduce the above\n"
              << "      copyright notice, this list of conditions and the following\n"
              << "      disclaimer in the documentation and/or other materials provided\n"
              << "      with the distribution.\n"
              << "\n"
              << "    * Neither the name of Sandia Corporation nor the names of its\n"
              << "      contributors may be used to endorse or promote products derived\n"
              << "      from this software without specific prior written permission.\n"
              << "\n"
              << "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
              << "'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
              << "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
              << "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
              << "OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
              << "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n"
              << "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n"
              << "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n"
              << "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
              << "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n"
              << "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n";
    exit(EXIT_SUCCESS);
  }

  // Parse remaining options as directory paths.
  if (option_index < argc) {
    basename_ = argv[option_index];

    if (options_.retrieve("auto")) {
      // Determine Root, Proc, Extension, and Basename automatically
      // by parsing the basename_ entered by the user.  Assumed to be
      // in the form: "/directory/sub/basename.ext.#proc.34"
      bool success = decompose_filename(basename_);
      if (!success) {
        std::cerr
            << "\nERROR: (EPU) If the '-auto' option is specified, the basename must specify an "
               "existing filename.\n"
            << "       The entered basename does not contain an extension or processor count.\n";
        return false;
      }
    }
  }
  else {
    std::cerr << "\nERROR: (EPU) basename not specified\n\n";
    return false;
  }
  return true;
}