Example #1
0
bool Excn::ExodusFile::create_output(const SystemInterface& si)
  // Create output file...
{
  outputFilename_ = si.outputName_;

  int mode = EX_CLOBBER | exodusMode_;
  if (si.ints_64_bit())
    mode |= EX_ALL_INT64_DB;
  
  std::cout << "Output:   '" << outputFilename_ << "'" << std::endl;
  outputId_ = ex_create(outputFilename_.c_str(), mode,
			&cpuWordSize_, &ioWordSize_);
  if (outputId_ < 0) {
    std::cerr << "Cannot open file '" << outputFilename_ << "'" << std::endl;
    return false;
  }
  std::cout << "IO Word size is " << ioWordSize_ << " bytes.\n";
  ex_set_max_name_length(outputId_, maximumNameLength_);
  return true;
}
Example #2
0
bool Excn::ExodusFile::initialize(const SystemInterface& si)
{
  // See if we can keep files open 
  size_t max_files = get_free_descriptor_count();
  if (si.inputFiles_.size() <= max_files) {
    keepOpen_ = true;
    if (si.debug() & 1)
      std::cout << "Files kept open... (Max open = " << max_files << ")\n\n";
  } else {
    keepOpen_ = false;
    std::cout << "Single file mode... (Max open = " << max_files << ")\n"
	      << "Consider using the -subcycle option for faster execution...\n\n";
  }

  float version = 0.0;

  // create exo names
  filenames_.resize(si.inputFiles_.size());
  fileids_.resize(si.inputFiles_.size());
  
  int int_byte_size_api = 4;
  if (si.ints_64_bit())
    int_byte_size_api = 8;
  
  int overall_max_name_length = 0;
  for(size_t p = 0; p < si.inputFiles_.size(); p++) {
    std::string name = si.inputFiles_[p];

    filenames_[p] = name;

    if (p == 0) {
      int cpu_word_size  = sizeof(float);
      int io_wrd_size   = 0;
      int exoid = ex_open(filenames_[p].c_str(),
			  EX_READ, &cpu_word_size,
			  &io_wrd_size, &version);
      if (exoid < 0) {
	std::cerr << "Cannot open file '" << filenames_[p] << "'" << std::endl;
	return false;
      }

      int max_name_length = ex_inquire_int(exoid, EX_INQ_DB_MAX_USED_NAME_LENGTH);
      if (max_name_length > overall_max_name_length)
	overall_max_name_length = max_name_length;

      ex_close(exoid);

      if (io_wrd_size < (int)sizeof(float))
	io_wrd_size = sizeof(float);

      ioWordSize_ = io_wrd_size;
      cpuWordSize_ = io_wrd_size;

      if (ex_int64_status(exoid & EX_ALL_INT64_DB) || si.ints_64_bit()) {
	exodusMode_ = EX_ALL_INT64_API;
      }
    }

    if (keepOpen_ || p == 0) {
      int io_wrd_size   = 0;
      int mode = EX_READ | exodusMode_;

      fileids_[p] = ex_open(filenames_[p].c_str(),
			    mode, &cpuWordSize_,
			    &io_wrd_size, &version);
      if (fileids_[p] < 0) {
	std::cerr << "Cannot open file '" << filenames_[p] << "'" << std::endl;
	return false;
      }

      SMART_ASSERT(ioWordSize_ == io_wrd_size)(ioWordSize_)(io_wrd_size);
    }
    
    std::cout << "Part " << p+1 << ": '" << name.c_str() << "'" << std::endl;
  }

  maximumNameLength_ = overall_max_name_length;
  for(size_t p = 0; p < si.inputFiles_.size(); p++) {
    ex_set_max_name_length(fileids_[p], maximumNameLength_);
  }

  return true;
}