-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redo the CMake examples; add Ioss example
- Loading branch information
1 parent
9e352f4
commit 5559f92
Showing
6 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1...3.26) | ||
project(IossCMakeExample VERSION 1.0 LANGUAGES CXX) | ||
|
||
#### C++ IOSS #### | ||
find_package(SEACASIoss CONFIG) | ||
add_executable(IossExample IossExample.C) | ||
target_link_libraries(IossExample PRIVATE SEACASIoss::all_libs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <Ionit_Initializer.h> | ||
#include <Ioss_DatabaseIO.h> | ||
#include <Ioss_IOFactory.h> | ||
#include <Ioss_Region.h> | ||
#include <Ioss_Utils.h> | ||
|
||
#include <assert.h> | ||
#include <iostream> | ||
#include <string> | ||
|
||
int main(int argc, char *argv[]) { | ||
#ifdef SEACAS_HAVE_MPI | ||
MPI_Init(&argc, &argv); | ||
ON_BLOCK_EXIT(MPI_Finalize); | ||
#endif | ||
|
||
if (argc == 1) { | ||
std::cerr << "SYNTAX: " << argv[0] | ||
<< " '--show-config' or 'filename'\n" | ||
" Will either show the Ioss build configuration\n" | ||
" Or will show a summary of the data in `filename`\n"; | ||
std::exit(EXIT_SUCCESS); | ||
} | ||
|
||
Ioss::Init::Initializer io; | ||
std::string filename = argv[1]; | ||
if (filename == "--show-config") { | ||
std::cerr << Ioss::IOFactory::show_configuration() << "\n"; | ||
} else { | ||
auto dbtype = Ioss::Utils::get_type_from_file(filename); | ||
auto *dbi = Ioss::IOFactory::create(dbtype, filename, Ioss::READ_RESTART, | ||
Ioss::ParallelUtils::comm_world()); | ||
|
||
if (dbi == NULL || !dbi->ok(true)) { | ||
std::exit(EXIT_FAILURE); | ||
} | ||
|
||
// NOTE: 'region' owns 'dbi' pointer at this time and will close | ||
// and call dbi destructor. | ||
Ioss::Region region(dbi, "example_region"); | ||
region.output_summary(std::cerr); | ||
} | ||
} |