/home/runner/work/spades/spades/Source/main.cpp File Reference
SPADES API
|
main.cpp File Reference
#include <AMReX.H>
#include <AMReX_ParmParse.H>
#include <AMReX_MultiFab.H>
#include <AMReX_iMultiFab.H>
#include <AMReX_FileSystem.H>
#include <typeinfo>
#include "Constants.H"
#include "RunTime.H"
#include "SPADES.H"
#include "ConsoleIO.H"
Include dependency graph for main.cpp:
Functions | |
int | main (int argc, char *argv[]) |
Main function. | |
Function Documentation
◆ main()
int main | ( | int | argc, |
char * | argv[] ) |
Main function.
- Parameters
-
argc [in] An integer argument count of the command line arguments argv [in] An argument vector of the command line arguments
- Returns
- an integer 0 upon exit success
19{
20#ifdef AMREX_USE_MPI
21 MPI_Init(&argc, &argv);
22#endif
23
24 using namespace amrex::mpidatatypes;
25
26 if (argc < 2) {
27 // Print usage and exit with error code if no input file was provided.
28 spades::io::print_usage(MPI_COMM_WORLD, std::cout);
30 MPI_COMM_WORLD, "No input file provided. Exiting!!");
31 return 1;
32 }
33
34 // Look for "-h" or "--help" flag and print usage
35 for (auto i = 1; i < argc; i++) {
36 const std::string param(argv[i]);
37 if ((param == "--help") || (param == "-h")) {
38 spades::io::print_banner(MPI_COMM_WORLD, std::cout);
39 spades::io::print_usage(MPI_COMM_WORLD, std::cout);
40 return 0;
41 }
42 }
43
44 if (!amrex::FileSystem::Exists(std::string(argv[1]))) {
45 // Print usage and exit with error code if we cannot find the input file
46 spades::io::print_usage(MPI_COMM_WORLD, std::cout);
48 MPI_COMM_WORLD, "Input file does not exist = " +
49 std::string(argv[1]) + ". Exiting!!");
50 return 1;
51 }
52
53 spades::io::print_banner(MPI_COMM_WORLD, std::cout);
54
55 amrex::Initialize(argc, argv);
56
57 {
58 BL_PROFILE("SPADES::main()");
59
60 amrex::ParmParse pp("spades");
61 std::string model_name;
62 pp.get("model", model_name);
63 create_and_run_model(model_name);
64 }
65
66 amrex::Finalize();
67#ifdef AMREX_USE_MPI
68 MPI_Finalize();
69#endif
70
71 return 0;
72}
void print_banner(MPI_Comm comm, std::ostream &out)
Print SPADES banner.
Definition ConsoleIO.cpp:60
void print_usage(MPI_Comm comm, std::ostream &out)
Print SPADES usage.
Definition ConsoleIO.cpp:22
void print_error(MPI_Comm comm, const std::string &msg)
Print SPADES error.
Definition ConsoleIO.cpp:41
Here is the call graph for this function:
Generated by