diff --git a/Src/Base/AMReX_ParmParse.H b/Src/Base/AMReX_ParmParse.H index cc9588793d..802997b6e9 100644 --- a/Src/Base/AMReX_ParmParse.H +++ b/Src/Base/AMReX_ParmParse.H @@ -60,6 +60,9 @@ class RealVect; // '\n's. The "FILE = " definition is special. Rather than just // adding this entry to the database, it reads the contents of // into the database. +// For CI/CD workflows and out-of-source tests, the environment variable +// AMREX_INPUTS_FILE_PREFIX can be set to prefix every FILE = +// with a custom path. // // ParmParse stores all entries in a static table which is built the // first time a ParmParse object is constructed (usually in main()). diff --git a/Src/Base/AMReX_ParmParse.cpp b/Src/Base/AMReX_ParmParse.cpp index df1e18e9b0..88adac3395 100644 --- a/Src/Base/AMReX_ParmParse.cpp +++ b/Src/Base/AMReX_ParmParse.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -407,6 +408,14 @@ read_file (const char* fname, ParmParse::Table& tab) // if ( fname != nullptr && fname[0] != 0 ) { + std::string filename = fname; + + // optional prefix to search files in + char const *amrex_inputs_file_prefix = std::getenv("AMREX_INPUTS_FILE_PREFIX"); + if (amrex_inputs_file_prefix != nullptr) { + filename = std::string(amrex_inputs_file_prefix) + filename; + } + #ifdef AMREX_USE_MPI if (ParallelDescriptor::Communicator() == MPI_COMM_NULL) { @@ -415,7 +424,6 @@ read_file (const char* fname, ParmParse::Table& tab) #endif Vector fileCharPtr; - std::string filename = fname; ParallelDescriptor::ReadAndBcastFile(filename, fileCharPtr); std::istringstream is(fileCharPtr.data());