Exemplo n.º 1
0
void DatabaseIO::initialize(const Ioss::Region *region) const
{
    if (!initialized_) {
        assert(layout_ == NULL);
        assert(legend_ == NULL);

        DatabaseIO *new_this = const_cast<DatabaseIO*>(this);

        if (properties.exists("FILE_FORMAT")) {
            std::string format = properties.get("FILE_FORMAT").get_string();
            if (Ioss::Utils::case_strcmp(format, "spyhis") == 0)
                new_this->fileFormat = SPYHIS;
        }

        bool append = open_create_behavior() == Ioss::DB_APPEND;

        if (util().parallel_rank() == 0) {
            new_this->logStream = open_stream(get_filename().c_str(),
                                              &(new_this->streamNeedsDelete),
                                              append);
        } else {
            // All processors except processor 0
            new_this->logStream = NULL;
        }

        // Pull variables from the regions property data...
        if (properties.exists("TIME_STAMP_FORMAT")) {
            new_this->tsFormat = properties.get("TIME_STAMP_FORMAT").get_string();
        }

        if (properties.exists("PRECISION")) {
            new_this->precision_ = properties.get("PRECISION").get_int();
        }

        if (properties.exists("SHOW_LABELS")) {
            new_this->showLabels = (properties.get("SHOW_LABELS").get_int() == 1);
        }

        if (properties.exists("SHOW_LEGEND")) {
            new_this->showLegend = (properties.get("SHOW_LEGEND").get_int() == 1 && !new_this->appendOutput);
        }

        if (fileFormat == SPYHIS) {
            new_this->showLegend = true;
            new_this->showLabels = false;
            new_this->tsFormat = "";
        }

        if (showLegend) {
            new_this->legend_ = new Layout(false, precision_);
            if (!tsFormat.empty()) {
                new_this->legend_->add_literal("+");
                new_this->legend_->add_literal(time_stamp(tsFormat));
                new_this->legend_->add_literal(" ");
            }
            if (!fileFormat == SPYHIS)
                new_this->legend_->add_literal("Legend: ");

            if (!tsFormat.empty()) {
                new_this->legend_->add_literal("WallTime, ");
            }

            if (fileFormat == SPYHIS)
                new_this->legend_->add_literal("Time, ");
        }
        new_this->initialized_ = true;
    }
}
Exemplo n.º 2
0
  void DatabaseIO::initialize(const Ioss::Region *region) const
  {
    if (!initialized_) {
      assert(layout_ == NULL);
      assert(legend_ == NULL);

      DatabaseIO *new_this = const_cast<DatabaseIO*>(this);

      if (properties.exists("FIELD_SEPARATOR")) {
	new_this->separator_ = properties.get("FIELD_SEPARATOR").get_string();
      }

      if (properties.exists("FILE_FORMAT")) {
	std::string format = properties.get("FILE_FORMAT").get_string();
	if (Ioss::Utils::case_strcmp(format, "spyhis") == 0)
	  new_this->fileFormat = SPYHIS;
      }

      bool append = open_create_behavior() == Ioss::DB_APPEND;

      if (util().parallel_rank() == 0) {

        new_this->logStream = open_stream(get_filename(),
            &(new_this->streamNeedsDelete),
            append);

        if (new_this->logStream == NULL) {
	  Ioss::FileInfo path = Ioss::FileInfo(get_filename());
	  Ioss::Utils::create_path(path.pathname());
	  new_this->logStream = open_stream(get_filename(),
              &(new_this->streamNeedsDelete),
              append);
        }
      } else {
	// All processors except processor 0
	new_this->logStream = NULL;
      }

      // Pull variables from the regions property data...
      if (properties.exists("TIME_STAMP_FORMAT")) {
	new_this->tsFormat = properties.get("TIME_STAMP_FORMAT").get_string();
      }

      if (properties.exists("SHOW_TIME_STAMP")) {
	bool show_time_stamp = properties.get("SHOW_TIME_STAMP").get_int() == 1;
	if (!show_time_stamp) {
	  new_this->tsFormat="";
	}
      }

      if (properties.exists("PRECISION")) {
	new_this->precision_ = properties.get("PRECISION").get_int();
      }

      if (properties.exists("FIELD_WIDTH")) {
	new_this->fieldWidth_ = properties.get("FIELD_WIDTH").get_int();
      } else {
	// +1.xxxxxxe+00 The x count is the precision the "+1.e+00" is the 7
	new_this->fieldWidth_ = precision_ + 7;
      }	

      if (properties.exists("SHOW_LABELS")) {
	new_this->showLabels = (properties.get("SHOW_LABELS").get_int() == 1);
      }

      if (properties.exists("SHOW_LEGEND")) {
	new_this->showLegend = (properties.get("SHOW_LEGEND").get_int() == 1 && !new_this->appendOutput);
      }

      if (properties.exists("SHOW_TIME_FIELD")) {
	new_this->addTimeField = (properties.get("SHOW_TIME_FIELD").get_int() == 1);
      }

      if (fileFormat == SPYHIS) {
	new_this->addTimeField = true;
	new_this->showLegend = true;
	new_this->showLabels = false;
	new_this->tsFormat = "";
      }
      
      if (showLegend) {
	new_this->legend_ = new Layout(false, precision_, separator_, fieldWidth_);
	if (!tsFormat.empty()) {
	  new_this->legend_->add_literal("+");
	  new_this->legend_->add_literal(time_stamp(tsFormat));
	  new_this->legend_->add_literal(" ");
	}

	if (addTimeField) {
	  new_this->legend_->add_legend("Time");
	}
      }
      new_this->initialized_ = true;
    }
  }
Exemplo n.º 3
0
  void DatabaseIO::initialize(const Ioss::Region * /*region*/) const
  {
    if (!initialized_) {
      assert(layout_ == nullptr);
      assert(legend_ == nullptr);

      DatabaseIO *new_this = const_cast<DatabaseIO *>(this);

      if (properties.exists("FIELD_SEPARATOR")) {
        new_this->separator_ = properties.get("FIELD_SEPARATOR").get_string();
      }

      if (properties.exists("FILE_FORMAT")) {
        std::string format = properties.get("FILE_FORMAT").get_string();
        if (Ioss::Utils::case_strcmp(format, "spyhis") == 0) {
          new_this->fileFormat = SPYHIS;
        }
      }

      bool append = open_create_behavior() == Ioss::DB_APPEND;

      // Try to open file...
      new_this->logStream = nullptr;
      if (util().parallel_rank() == 0) {
        new_this->logStream = open_stream(get_filename(), &(new_this->streamNeedsDelete), append);

        if (new_this->logStream == nullptr) {
          std::ostringstream errmsg;
          errmsg << "ERROR: Could not create heartbeat file '" << get_filename() << "'\n";
          IOSS_ERROR(errmsg);
        }
      }

      // Pull variables from the regions property data...
      if (properties.exists("TIME_STAMP_FORMAT")) {
        new_this->tsFormat = properties.get("TIME_STAMP_FORMAT").get_string();
      }

      if (properties.exists("SHOW_TIME_STAMP")) {
        bool show_time_stamp = properties.get("SHOW_TIME_STAMP").get_int() == 1;
        if (!show_time_stamp) {
          new_this->tsFormat = "";
        }
      }

      if (properties.exists("PRECISION")) {
        new_this->precision_ = properties.get("PRECISION").get_int();
      }

      if (properties.exists("FIELD_WIDTH")) {
        new_this->fieldWidth_ = properties.get("FIELD_WIDTH").get_int();
      }
      else {
        // +1.xxxxxxe+00 The x count is the precision the "+1.e+00" is the 7
        new_this->fieldWidth_ = precision_ + 7;
      }

      if (properties.exists("SHOW_LABELS")) {
        new_this->showLabels = (properties.get("SHOW_LABELS").get_int() == 1);
      }

      if (properties.exists("SHOW_LEGEND")) {
        new_this->showLegend =
            (properties.get("SHOW_LEGEND").get_int() == 1 && !new_this->appendOutput);
      }

      if (properties.exists("SHOW_TIME_FIELD")) {
        new_this->addTimeField = (properties.get("SHOW_TIME_FIELD").get_int() == 1);
      }

      if (fileFormat == SPYHIS) {
        new_this->addTimeField = true;
        new_this->showLegend   = true;
        new_this->showLabels   = false;
        new_this->tsFormat     = "";
      }

      if (showLegend) {
        new_this->legend_ = new Layout(false, precision_, separator_, fieldWidth_);
        if (!tsFormat.empty()) {
          new_this->legend_->add_literal("+");
          new_this->legend_->add_literal(time_stamp(tsFormat));
          new_this->legend_->add_literal(" ");
        }

        if (addTimeField) {
          if (fileFormat == SPYHIS) {
            new_this->legend_->add_legend("TIME");
          }
          else {
            new_this->legend_->add_legend("Time");
          }
        }
      }
      new_this->initialized_ = true;
    }
  }