diff --git a/Src/Amr/AMReX_AmrLevel.cpp b/Src/Amr/AMReX_AmrLevel.cpp index 7cdd83e1cae..ab16f6ba827 100644 --- a/Src/Amr/AMReX_AmrLevel.cpp +++ b/Src/Amr/AMReX_AmrLevel.cpp @@ -726,12 +726,13 @@ FillPatchIterator::FillPatchIterator (AmrLevel& amrlevel, #endif } -static +namespace { bool NeedToTouchUpPhysCorners (const Geometry& geom) { return geom.isAnyPeriodic() && !geom.isAllPeriodic(); } +} void FillPatchIteratorHelper::Initialize (int boxGrow, @@ -1154,7 +1155,8 @@ FillPatchIterator::FillFromTwoLevels (Real time, int idx, int scomp, int dcomp, desc.getBCs(),scomp); } -static +namespace { + bool HasPhysBndry (const Box& b, const Box& dmn, @@ -1174,7 +1176,6 @@ HasPhysBndry (const Box& b, return false; } -static void FixUpPhysCorners (FArrayBox& fab, AmrLevel& TheLevel, @@ -1258,6 +1259,8 @@ FixUpPhysCorners (FArrayBox& fab, } } +} + void FillPatchIteratorHelper::fill (FArrayBox& fab, int dcomp, diff --git a/Src/AmrCore/AMReX_Cluster.cpp b/Src/AmrCore/AMReX_Cluster.cpp index 5383b9301f5..7c9ecc1d87a 100644 --- a/Src/AmrCore/AMReX_Cluster.cpp +++ b/Src/AmrCore/AMReX_Cluster.cpp @@ -148,7 +148,8 @@ Cluster::minBox () noexcept // Finds best cut location in histogram. // -static +namespace { + int FindCut (const int* hist, int lo, @@ -236,7 +237,6 @@ FindCut (const int* hist, return lo + cutpoint; } -namespace { // // Predicate in call to std::partition() in Cluster::chop(). // diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index 783a06504be..c9d1a7feef8 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -194,7 +194,9 @@ ErrorList::operator[] (int k) const noexcept return *vec[k]; } -static const char* err_name[] = { "Special", "Standard", "UseAverage" }; +namespace { + const char* err_name[] = { "Special", "Standard", "UseAverage" }; +} std::ostream& operator << (std::ostream& os, diff --git a/Src/Base/AMReX_DistributionMapping.cpp b/Src/Base/AMReX_DistributionMapping.cpp index 9350f9203d1..8dce304f424 100644 --- a/Src/Base/AMReX_DistributionMapping.cpp +++ b/Src/Base/AMReX_DistributionMapping.cpp @@ -570,7 +570,7 @@ struct WeightedBoxList } }; -static +namespace { void knapsack (const std::vector& wgts, int nprocs, @@ -712,6 +712,7 @@ top: ; } } } +} void DistributionMapping::KnapSackDoIt (const std::vector& wgts, @@ -1171,7 +1172,7 @@ namespace { } } -static +namespace { void Distribute (const std::vector& tokens, const std::vector& wgts, @@ -1254,6 +1255,7 @@ Distribute (const std::vector& tokens, BL_ASSERT(cnt == tokens.size()); #endif } +} void DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes, diff --git a/Src/Base/AMReX_FabConv.cpp b/Src/Base/AMReX_FabConv.cpp index 522216aadd1..e8dd870a058 100644 --- a/Src/Base/AMReX_FabConv.cpp +++ b/Src/Base/AMReX_FabConv.cpp @@ -170,7 +170,7 @@ RealDescriptor::clone () const // This exists solely to support reading "old" FABs. // -static +namespace { const int* selectOrdering (int prec, int ordering) @@ -208,6 +208,7 @@ selectOrdering (int prec, } return nullptr; } +} // // This is here solely to support reading "old" FABs. @@ -293,7 +294,7 @@ _pd_get_bit (char const* base, // for longer fields // -static +namespace { Long _pd_extract_field (char const* in, int offs, @@ -367,7 +368,6 @@ _pd_extract_field (char const* in, // template -static void _pd_btrvout (char* out, Long nitems) { @@ -387,8 +387,10 @@ _pd_btrvout (char* out, Long nitems) } } -const int BitsMax = 8*sizeof(Long); -const int REVERSE_ORDER = 2; +constexpr int BitsMax = 8*sizeof(Long); +constexpr int REVERSE_ORDER = 2; + +} // // Copy the least significant NB bits from the given Long into the byte array @@ -487,7 +489,7 @@ _pd_set_bit (char* base, int offs) // on input. // -static +namespace { void _pd_reorder (char* arr, Long nitems, @@ -512,7 +514,6 @@ _pd_reorder (char* arr, // from inord to outord. // -static void permute_real_word_order (void* out, const void* in, @@ -786,7 +787,6 @@ PD_fconvert (void* out, _pd_reorder((char*)out, nitems, outbytes, outord); } -static void PD_fixdenormals (void* out, Long nitems, @@ -816,13 +816,15 @@ PD_fixdenormals (void* out, } } +} + // // It's really sad that I need to do this ... // #undef GETARRAY +namespace { #define GETARRAY(TYPE) \ -static \ void \ getarray (std::istream& is, \ Vector< TYPE >& ar) \ @@ -852,11 +854,12 @@ getarray (std::istream& is, \ } GETARRAY(int) GETARRAY(Long) +} #undef GETARRAY #undef PUTARRAY +namespace { #define PUTARRAY(TYPE) \ -static \ void \ putarray (std::ostream& os, \ const Vector< TYPE >& ar) \ @@ -874,6 +877,7 @@ putarray (std::ostream& os, \ } PUTARRAY(int) PUTARRAY(Long) +} #undef PUTARRAY std::ostream& @@ -917,7 +921,7 @@ operator>> (std::istream& is, return is; } -static +namespace { void PD_convert (void* out, const void* in, @@ -960,6 +964,7 @@ PD_convert (void* out, PD_fixdenormals(out, nitems, ord.format(), ord.order()); } } +} // // Convert nitems in RealDescriptor format to native Real format. diff --git a/Src/Base/AMReX_GpuControl.H b/Src/Base/AMReX_GpuControl.H index 0f21213a86d..1532045bec4 100644 --- a/Src/Base/AMReX_GpuControl.H +++ b/Src/Base/AMReX_GpuControl.H @@ -184,13 +184,13 @@ namespace Gpu { #else - [[nodiscard]] inline static constexpr bool inLaunchRegion () { return false; } - [[nodiscard]] inline static constexpr bool notInLaunchRegion () { return true; } - [[nodiscard]] inline static constexpr bool setLaunchRegion (bool) { return false; } + [[nodiscard]] inline constexpr bool inLaunchRegion () { return false; } + [[nodiscard]] inline constexpr bool notInLaunchRegion () { return true; } + [[nodiscard]] inline constexpr bool setLaunchRegion (bool) { return false; } - [[nodiscard]] inline static constexpr bool inGraphRegion () { return false; } - [[nodiscard]] inline static constexpr bool notInGraphRegion () { return true; } - [[nodiscard]] inline static constexpr bool setGraphRegion (bool) { return false; } + [[nodiscard]] inline constexpr bool inGraphRegion () { return false; } + [[nodiscard]] inline constexpr bool notInGraphRegion () { return true; } + [[nodiscard]] inline constexpr bool setGraphRegion (bool) { return false; } struct [[nodiscard]] LaunchSafeGuard { @@ -202,10 +202,10 @@ namespace Gpu { explicit GraphSafeGuard (bool) {} }; - [[nodiscard]] inline static constexpr bool inSingleStreamRegion () { return false; } - [[nodiscard]] inline static constexpr bool inNoSyncRegion () { return true; } - [[nodiscard]] inline static constexpr bool setSingleStreamRegion (bool) { return false; } - [[nodiscard]] inline static constexpr bool setNoSyncRegion (bool) { return true; } + [[nodiscard]] inline constexpr bool inSingleStreamRegion () { return false; } + [[nodiscard]] inline constexpr bool inNoSyncRegion () { return true; } + [[nodiscard]] inline constexpr bool setSingleStreamRegion (bool) { return false; } + [[nodiscard]] inline constexpr bool setNoSyncRegion (bool) { return true; } struct [[nodiscard]] SingleStreamRegion {}; struct [[nodiscard]] NoSyncRegion {}; diff --git a/Src/Base/AMReX_GpuLaunch.H b/Src/Base/AMReX_GpuLaunch.H index ed61eadc13b..620659ff43f 100644 --- a/Src/Base/AMReX_GpuLaunch.H +++ b/Src/Base/AMReX_GpuLaunch.H @@ -77,11 +77,11 @@ namespace amrex { namespace Gpu { #ifdef AMREX_USE_GPU - static constexpr std::size_t numThreadsPerBlockParallelFor () { + inline constexpr std::size_t numThreadsPerBlockParallelFor () { return AMREX_GPU_MAX_THREADS; } #else - static constexpr std::size_t numThreadsPerBlockParallelFor () { return 0; } + inline constexpr std::size_t numThreadsPerBlockParallelFor () { return 0; } #endif // ************************************************ diff --git a/Src/Base/AMReX_ParmParse.cpp b/Src/Base/AMReX_ParmParse.cpp index 78a149fb55c..741a055b95e 100644 --- a/Src/Base/AMReX_ParmParse.cpp +++ b/Src/Base/AMReX_ParmParse.cpp @@ -29,11 +29,13 @@ extern "C" void amrex_finalize_namelist (); namespace amrex { +namespace { #ifdef AMREX_XSDK -static bool finalize_verbose = false; + bool finalize_verbose = false; #else -static bool finalize_verbose = true; + bool finalize_verbose = true; #endif +} std::string const ParmParse::FileKeyword = "FILE"; @@ -1178,7 +1180,8 @@ ParmParse::appendTable(ParmParse::Table& tab) g_table.splice(g_table.end(), tab); } -static +namespace { + bool unused_table_entries_q (const ParmParse::Table& table, const std::string& prefix = std::string()) { @@ -1215,7 +1218,6 @@ unused_table_entries_q (const ParmParse::Table& table, const std::string& prefix return false; } -static void finalize_table (const std::string& pfx, const ParmParse::Table& table) { @@ -1243,6 +1245,8 @@ finalize_table (const std::string& pfx, const ParmParse::Table& table) } } +} + void ParmParse::Initialize (int argc, char** argv, @@ -1278,7 +1282,7 @@ ParmParse::hasUnusedInputs (const std::string& prefix) return unused_table_entries_q(g_table, prefix); } -static +namespace { void get_entries_under_prefix (std::vector& found_entries, const ParmParse::Table& table, @@ -1307,6 +1311,7 @@ get_entries_under_prefix (std::vector& found_entries, } } } +} std::vector ParmParse::getUnusedInputs (const std::string& prefix) diff --git a/Src/Base/AMReX_VisMF.cpp b/Src/Base/AMReX_VisMF.cpp index 912be0b9b99..064d94ce757 100644 --- a/Src/Base/AMReX_VisMF.cpp +++ b/Src/Base/AMReX_VisMF.cpp @@ -11,9 +11,11 @@ namespace amrex { -static const char *TheMultiFabHdrFileSuffix = "_H"; -static const char *FabFileSuffix = "_D_"; -static const char *TheFabOnDiskPrefix = "FabOnDisk:"; +namespace { + const char *TheMultiFabHdrFileSuffix = "_H"; + const char *FabFileSuffix = "_D_"; + const char *TheFabOnDiskPrefix = "FabOnDisk:"; +} std::map VisMF::persistentIFStreams; @@ -192,7 +194,8 @@ operator>> (std::istream& is, return is; } -static +namespace { + std::ostream& operator<< (std::ostream& os, const Vector< Vector >& ar) @@ -217,7 +220,6 @@ operator<< (std::ostream& os, return os; } -static std::istream& operator>> (std::istream& is, Vector< Vector >& ar) @@ -265,6 +267,8 @@ operator>> (std::istream& is, return is; } +} + std::ostream& operator<< (std::ostream &os, const VisMF::Header &hd) diff --git a/Src/Base/AMReX_parstream.cpp b/Src/Base/AMReX_parstream.cpp index 824b9041ecc..e7b204f0d12 100644 --- a/Src/Base/AMReX_parstream.cpp +++ b/Src/Base/AMReX_parstream.cpp @@ -40,12 +40,14 @@ namespace amrex // the shared variables - static std::string s_pout_filename ; - static std::string s_pout_basename ; - static std::ofstream s_pout ; +namespace { - static bool s_pout_init = false ; - static bool s_pout_open = false ; + std::string s_pout_filename ; + std::string s_pout_basename ; + std::ofstream s_pout ; + + bool s_pout_init = false ; + bool s_pout_open = false ; //////////////////////////////////////////////////////////////// @@ -54,7 +56,7 @@ namespace amrex #ifdef BL_USE_MPI // in parallel, compute the filename give the basename //[NOTE: dont call this before MPI is initialized.] - static void setFileName() + void setFileName() { int outInterv = 1; ParmParse pp("amrex"); @@ -76,7 +78,7 @@ namespace amrex } // in parallel, close the file if nec., open it and check for success - static void openFile() + void openFile() { if ( s_pout_open ) { @@ -90,18 +92,20 @@ namespace amrex #else // in serial, filename is always cout - static void setFileName() + void setFileName() { s_pout_filename = "cout" ; } // in serial, this does absolutely nothing - static void openFile() + void openFile() { amrex::ignore_unused(s_pout); } #endif +} + //////////////////////////////////////////////////////////////// /// the stream that all output except error msgs should use diff --git a/Src/Base/Parser/AMReX_IParser_Exe.cpp b/Src/Base/Parser/AMReX_IParser_Exe.cpp index cabf8203349..062b7d9ffa4 100644 --- a/Src/Base/Parser/AMReX_IParser_Exe.cpp +++ b/Src/Base/Parser/AMReX_IParser_Exe.cpp @@ -2,7 +2,8 @@ namespace amrex { -static int iparser_local_symbol_index (struct iparser_symbol* sym, Vector& local_variables) +namespace { +int iparser_local_symbol_index (struct iparser_symbol* sym, Vector& local_variables) { auto r = std::find_if(local_variables.rbegin(), local_variables.rend(), [=] (char* i) { return std::strcmp(sym->name, i) == 0; }); @@ -12,6 +13,7 @@ static int iparser_local_symbol_index (struct iparser_symbol* sym, Vector return -1; } } +} void iparser_compile_exe_size (struct iparser_node* node, char*& p, std::size_t& exe_size, diff --git a/Src/Base/Parser/AMReX_IParser_Y.cpp b/Src/Base/Parser/AMReX_IParser_Y.cpp index 87a77503132..cfb036de96e 100644 --- a/Src/Base/Parser/AMReX_IParser_Y.cpp +++ b/Src/Base/Parser/AMReX_IParser_Y.cpp @@ -19,7 +19,9 @@ amrex_iparsererror (char const *s, ...) namespace amrex { -static struct iparser_node* iparser_root = nullptr; +namespace { + struct iparser_node* iparser_root = nullptr; +} // This is called by a bison rule to store the original AST in a static variable. void @@ -150,7 +152,8 @@ amrex_iparser_delete (struct amrex_iparser* iparser) std::free(iparser); } -static +namespace { + std::size_t iparser_aligned_size (std::size_t N) { @@ -160,7 +163,6 @@ iparser_aligned_size (std::size_t N) return x; } -static void* iparser_allocate (struct amrex_iparser* my_iparser, std::size_t N) { @@ -169,6 +171,8 @@ iparser_allocate (struct amrex_iparser* my_iparser, std::size_t N) return r; } +} + struct amrex_iparser* iparser_dup (struct amrex_iparser* source) { @@ -976,7 +980,8 @@ iparser_ast_optimize (struct iparser_node* node) } } -static +namespace { + void iparser_ast_print_f1 (struct iparser_f1* f1, std::string const& space, AllPrint& printer) { @@ -989,7 +994,6 @@ iparser_ast_print_f1 (struct iparser_f1* f1, std::string const& space, AllPrint& iparser_ast_print(f1->l, space+" ", printer); } -static void iparser_ast_print_f2 (struct iparser_f2* f2, std::string const& space, AllPrint& printer) { @@ -1038,7 +1042,6 @@ iparser_ast_print_f2 (struct iparser_f2* f2, std::string const& space, AllPrint& iparser_ast_print(f2->r, space+" ", printer); } -static void iparser_ast_print_f3 (struct iparser_f3* f3, std::string const& space, AllPrint& printer) { @@ -1055,6 +1058,8 @@ iparser_ast_print_f3 (struct iparser_f3* f3, std::string const& space, AllPrint& iparser_ast_print(f3->n3, more_space, printer); } +} + void iparser_ast_print (struct iparser_node* node, std::string const& space, AllPrint& printer) { diff --git a/Src/Base/Parser/AMReX_Parser_Y.cpp b/Src/Base/Parser/AMReX_Parser_Y.cpp index 75a58498c15..dc9caf9133d 100644 --- a/Src/Base/Parser/AMReX_Parser_Y.cpp +++ b/Src/Base/Parser/AMReX_Parser_Y.cpp @@ -19,7 +19,9 @@ amrex_parsererror (char const *s, ...) namespace amrex { -static struct parser_node* parser_root = nullptr; +namespace { + struct parser_node* parser_root = nullptr; +} // This is called by a bison rule to store the original AST in a static variable. void @@ -171,7 +173,8 @@ amrex_parser_delete (struct amrex_parser* parser) std::free(parser); } -static +namespace { + std::size_t parser_aligned_size (std::size_t N) { @@ -181,7 +184,6 @@ parser_aligned_size (std::size_t N) return x; } -static void* parser_allocate (struct amrex_parser* my_parser, std::size_t N) { @@ -190,6 +192,8 @@ parser_allocate (struct amrex_parser* my_parser, std::size_t N) return r; } +} + struct amrex_parser* parser_dup (struct amrex_parser* source) { @@ -1334,7 +1338,8 @@ parser_ast_optimize (struct parser_node* node) } } -static +namespace { + void parser_ast_print_f1 (struct parser_f1* f1, std::string const& space, std::ostream& printer) { @@ -1342,7 +1347,6 @@ parser_ast_print_f1 (struct parser_f1* f1, std::string const& space, std::ostrea parser_ast_print(f1->l, space+" ", printer); } -static void parser_ast_print_f2 (struct parser_f2* f2, std::string const& space, std::ostream& printer) { @@ -1351,7 +1355,6 @@ parser_ast_print_f2 (struct parser_f2* f2, std::string const& space, std::ostrea parser_ast_print(f2->r, space+" ", printer); } -static void parser_ast_print_f3 (struct parser_f3* f3, std::string const& space, std::ostream& printer) { @@ -1362,6 +1365,8 @@ parser_ast_print_f3 (struct parser_f3* f3, std::string const& space, std::ostrea parser_ast_print(f3->n3, more_space, printer); } +} + void parser_ast_print (struct parser_node* node, std::string const& space, std::ostream& printer) {