diff --git a/tests/ert/ui_tests/cli/test_run_flow_simulator.py b/tests/ert/ui_tests/cli/test_run_flow_simulator.py index 5ffdeb24942..13d173c3060 100644 --- a/tests/ert/ui_tests/cli/test_run_flow_simulator.py +++ b/tests/ert/ui_tests/cli/test_run_flow_simulator.py @@ -128,6 +128,39 @@ def test_ert_will_fetch_parallel_keyword_and_set_mpi_processes(): assert re.search(r"Threads per MPI process:\s+1", flow_stdout) +@pytest.mark.usefixtures("eightcells") +@pytest.mark.skipif(not shutil.which("flowrun"), reason="flowrun not available") +@pytest.mark.parametrize("num_cpu", [1, 2]) +def test_flow_will_always_obey_omp_num_threads_also_when_mpi_is_active(num_cpu): + """This part of flow Ert cannot control, and this scenario should thus be + avoided. However, if the users use SETENV manually it will happen. + SETENV takes precedence over plugin env configuration so configuriation of + the FLOW forward model through plugins will not help either.""" + deck = Path("EIGHTCELLS.DATA").read_text(encoding="utf-8") + assert "PARALLEL" not in deck + Path("flow.ert").write_text( + dedent(f""" + NUM_REALIZATIONS 1 + ECLBASE EIGHTCELLS + NUM_CPU {num_cpu} + DATA_FILE EIGHTCELLS.DATA + SETENV OMP_NUM_THREADS 2 + RUNPATH realization- + FORWARD_MODEL FLOW() + """).strip(), + encoding="utf-8", + ) + + run_cli(TEST_RUN_MODE, "--disable-monitoring", "flow.ert") + flow_stdout = Path("realization-0/FLOW.stdout.0").read_text(encoding="utf-8") + assert ( + "Warning: Environment variable OMP_NUM_THREADS takes precedence over the --threads-per-process" + in flow_stdout + ) + assert re.search(rf"Number of MPI processes:\s+{num_cpu}", flow_stdout) + assert re.search(r"Threads per MPI process:\s+2", flow_stdout) + + @pytest.mark.usefixtures("eightcells") @pytest.mark.skipif(not shutil.which("flowrun"), reason="flowrun not available") def test_num_cpu_wins_over_parallel_in_deck():