/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 "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
18{
19#ifdef AMREX_USE_MPI
20 MPI_Init(&argc, &argv);
21#endif
22
23 using namespace amrex::mpidatatypes;
24
25 if (argc < 2) {
26 // Print usage and exit with error code if no input file was provided.
27 spades::io::print_usage(MPI_COMM_WORLD, std::cout);
29 MPI_COMM_WORLD, "No input file provided. Exiting!!");
30 return 1;
31 }
32
33 // Look for "-h" or "--help" flag and print usage
34 for (auto i = 1; i < argc; i++) {
35 const std::string param(argv[i]);
36 if ((param == "--help") || (param == "-h")) {
37 spades::io::print_banner(MPI_COMM_WORLD, std::cout);
38 spades::io::print_usage(MPI_COMM_WORLD, std::cout);
39 return 0;
40 }
41 }
42
43 if (!amrex::FileSystem::Exists(std::string(argv[1]))) {
44 // Print usage and exit with error code if we cannot find the input file
45 spades::io::print_usage(MPI_COMM_WORLD, std::cout);
47 MPI_COMM_WORLD, "Input file does not exist = " +
48 std::string(argv[1]) + ". Exiting!!");
49 return 1;
50 }
51
52 spades::io::print_banner(MPI_COMM_WORLD, std::cout);
53
54 amrex::Initialize(argc, argv);
55
56 {
57 BL_PROFILE("SPADES::main()");
58
59 amrex::Real start_time = amrex::ParallelDescriptor::second();
60 amrex::Print() << "Initializing SPADES ..." << std::endl;
61
62 spades::SPADES spades_obj;
63 spades_obj.init_data();
64
65 amrex::Real init_time =
66 amrex::ParallelDescriptor::second() - start_time;
67 amrex::ParallelDescriptor::ReduceRealMax(
68 init_time, amrex::ParallelDescriptor::IOProcessorNumber());
69 amrex::Print() << "Initialization successful. Time elapsed = "
70 << init_time << std::endl;
71
72 spades_obj.evolve();
73
74 amrex::Real end_time = amrex::ParallelDescriptor::second() - start_time;
75 amrex::ParallelDescriptor::ReduceRealMax(
76 end_time, amrex::ParallelDescriptor::IOProcessorNumber());
77
78 amrex::Print() << "\n==============================================="
79 "================================================="
80 << std::endl
81 << std::endl;
82 amrex::Print() << "Time spent in init_data(): " << init_time
83 << std::endl;
84 amrex::Print() << "Time spent in evolve(): "
85 << end_time - init_time << std::endl;
86 }
87
88 amrex::Finalize();
89#ifdef AMREX_USE_MPI
90 MPI_Finalize();
91#endif
92
93 return 0;
94}
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