Skip to content

Commit 1d50bfc

Browse files
authored
Add a function for detecting whether amrex::Initialize has been called or not. (#2501)
1 parent 062a071 commit 1d50bfc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Src/Base/AMReX.H

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ namespace amrex
7676
std::ostream& a_oserr = std::cerr,
7777
ErrorHandler a_errorhandler = nullptr);
7878

79+
/**
80+
\brief Returns true if there are any currently-active and initialized
81+
AMReX instances (i.e. one for which amrex::Initialize has been called,
82+
and amrex::Finalize has not). Otherwise false.
83+
*/
84+
bool Initialized ();
85+
7986
void Finalize (AMReX* pamrex);
8087
void Finalize (); // Finalize the current top
8188
/**

Src/Base/AMReX.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
575575
return AMReX::top();
576576
}
577577

578+
bool
579+
amrex::Initialized ()
580+
{
581+
return !amrex::AMReX::empty();
582+
}
583+
578584
void
579585
amrex::Finalize ()
580586
{

0 commit comments

Comments
 (0)