We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
use MAX_MPI_TASKS_PER_NODE for core limit in test_schedular
The current scheme fails to run tests on small systems that should be okay even though they overload the node. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/lib/CIME/SystemTests/pet.py`
Content:
```
1 """
2 Implementation of the CIME PET test.  This class inherits from SystemTestsCommon
3 
4 This is an openmp test to determine that changing thread counts does not change answers.
5 (1) do an initial run where all components are threaded by default (suffix: base)
6 (2) do another initial run with nthrds=1 for all components (suffix: single_thread)
7 """
8 
9 from CIME.XML.standard_module_setup import *
10 from CIME.case_setup import case_setup
11 from CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo
12 
13 logger = logging.getLogger(__name__)
14 
15 class PET(SystemTestsCompareTwo):
16 
17     def __init__(self, case):
18         """
19         initialize a test object
20         """
21         SystemTestsCompareTwo.__init__(self, case,
22                                        separate_builds = False,
23                                        run_two_suffix = 'single_thread',
24                                        run_one_description = 'default threading',
25                                        run_two_description = 'threads set to 1')
26 
27     def _case_one_setup(self):
28         # first make sure that all components have threaded settings
29         for comp in self._case.get_values("COMP_CLASSES"):
30             if self._case.get_value("NTHRDS_{}".format(comp)) <= 1:
31                 self._case.set_value("NTHRDS_{}".format(comp), 2)
32 
33         # Need to redo case_setup because we may have changed the number of threads
34         case_setup(self._case, reset=True)
35 
36     def _case_two_setup(self):
37         #Do a run with all threads set to 1
38         for comp in self._case.get_values("COMP_CLASSES"):
39             self._case.set_value("NTHRDS_{}".format(comp), 1)
40 
41         # The need for this is subtle. On batch systems, the entire PET test runs
42         # under a single submission and that submission is configured based on
43         # the case settings for case 1, IE 2 threads for all components. This causes
44         # the procs-per-node to be half of what it would be for single thread. On some
45         # machines, if the mpiexec tries to exceed the procs-per-node that were given
46         # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of
47         # it original value prevents this.
48         self._case.set_value("MAX_TASKS_PER_NODE", int(self._case.get_value("MAX_TASKS_PER_NODE") / 2))
49 
50         # Need to redo case_setup because we may have changed the number of threads
51         case_setup(self._case, reset=True)
52
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scripts/lib/CIME/SystemTests/pet.py b/scripts/lib/CIME/SystemTests/pet.py
--- a/scripts/lib/CIME/SystemTests/pet.py
+++ b/scripts/lib/CIME/SystemTests/pet.py
@@ -46,6 +46,7 @@
         # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of
         # it original value prevents this.
         self._case.set_value("MAX_TASKS_PER_NODE", int(self._case.get_value("MAX_TASKS_PER_NODE") / 2))
+        self._case.set_value("MAX_MPITASKS_PER_NODE", int(self._case.get_value("MAX_MPITASKS_PER_NODE") / 2))
 
         # Need to redo case_setup because we may have changed the number of threads
         case_setup(self._case, reset=True)

{"golden_diff": "diff --git a/scripts/lib/CIME/SystemTests/pet.py b/scripts/lib/CIME/SystemTests/pet.py\n--- a/scripts/lib/CIME/SystemTests/pet.py\n+++ b/scripts/lib/CIME/SystemTests/pet.py\n@@ -46,6 +46,7 @@\n         # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of\n         # it original value prevents this.\n         self._case.set_value(\"MAX_TASKS_PER_NODE\", int(self._case.get_value(\"MAX_TASKS_PER_NODE\") / 2))\n+        self._case.set_value(\"MAX_MPITASKS_PER_NODE\", int(self._case.get_value(\"MAX_MPITASKS_PER_NODE\") / 2))\n \n         # Need to redo case_setup because we may have changed the number of threads\n         case_setup(self._case, reset=True)\n", "issue": "use MAX_MPI_TASKS_PER_NODE for core limit in test_schedular\nThe current scheme fails to run tests on small systems that should be okay even though they overload the node. \n", "before_files": [{"content": "\"\"\"\nImplementation of the CIME PET test.  This class inherits from SystemTestsCommon\n\nThis is an openmp test to determine that changing thread counts does not change answers.\n(1) do an initial run where all components are threaded by default (suffix: base)\n(2) do another initial run with nthrds=1 for all components (suffix: single_thread)\n\"\"\"\n\nfrom CIME.XML.standard_module_setup import *\nfrom CIME.case_setup import case_setup\nfrom CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo\n\nlogger = logging.getLogger(__name__)\n\nclass PET(SystemTestsCompareTwo):\n\n    def __init__(self, case):\n        \"\"\"\n        initialize a test object\n        \"\"\"\n        SystemTestsCompareTwo.__init__(self, case,\n                                       separate_builds = False,\n                                       run_two_suffix = 'single_thread',\n                                       run_one_description = 'default threading',\n                                       run_two_description = 'threads set to 1')\n\n    def _case_one_setup(self):\n        # first make sure that all components have threaded settings\n        for comp in self._case.get_values(\"COMP_CLASSES\"):\n            if self._case.get_value(\"NTHRDS_{}\".format(comp)) <= 1:\n                self._case.set_value(\"NTHRDS_{}\".format(comp), 2)\n\n        # Need to redo case_setup because we may have changed the number of threads\n        case_setup(self._case, reset=True)\n\n    def _case_two_setup(self):\n        #Do a run with all threads set to 1\n        for comp in self._case.get_values(\"COMP_CLASSES\"):\n            self._case.set_value(\"NTHRDS_{}\".format(comp), 1)\n\n        # The need for this is subtle. On batch systems, the entire PET test runs\n        # under a single submission and that submission is configured based on\n        # the case settings for case 1, IE 2 threads for all components. This causes\n        # the procs-per-node to be half of what it would be for single thread. On some\n        # machines, if the mpiexec tries to exceed the procs-per-node that were given\n        # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of\n        # it original value prevents this.\n        self._case.set_value(\"MAX_TASKS_PER_NODE\", int(self._case.get_value(\"MAX_TASKS_PER_NODE\") / 2))\n\n        # Need to redo case_setup because we may have changed the number of threads\n        case_setup(self._case, reset=True)\n", "path": "scripts/lib/CIME/SystemTests/pet.py"}], "after_files": [{"content": "\"\"\"\nImplementation of the CIME PET test.  This class inherits from SystemTestsCommon\n\nThis is an openmp test to determine that changing thread counts does not change answers.\n(1) do an initial run where all components are threaded by default (suffix: base)\n(2) do another initial run with nthrds=1 for all components (suffix: single_thread)\n\"\"\"\n\nfrom CIME.XML.standard_module_setup import *\nfrom CIME.case_setup import case_setup\nfrom CIME.SystemTests.system_tests_compare_two import SystemTestsCompareTwo\n\nlogger = logging.getLogger(__name__)\n\nclass PET(SystemTestsCompareTwo):\n\n    def __init__(self, case):\n        \"\"\"\n        initialize a test object\n        \"\"\"\n        SystemTestsCompareTwo.__init__(self, case,\n                                       separate_builds = False,\n                                       run_two_suffix = 'single_thread',\n                                       run_one_description = 'default threading',\n                                       run_two_description = 'threads set to 1')\n\n    def _case_one_setup(self):\n        # first make sure that all components have threaded settings\n        for comp in self._case.get_values(\"COMP_CLASSES\"):\n            if self._case.get_value(\"NTHRDS_{}\".format(comp)) <= 1:\n                self._case.set_value(\"NTHRDS_{}\".format(comp), 2)\n\n        # Need to redo case_setup because we may have changed the number of threads\n        case_setup(self._case, reset=True)\n\n    def _case_two_setup(self):\n        #Do a run with all threads set to 1\n        for comp in self._case.get_values(\"COMP_CLASSES\"):\n            self._case.set_value(\"NTHRDS_{}\".format(comp), 1)\n\n        # The need for this is subtle. On batch systems, the entire PET test runs\n        # under a single submission and that submission is configured based on\n        # the case settings for case 1, IE 2 threads for all components. This causes\n        # the procs-per-node to be half of what it would be for single thread. On some\n        # machines, if the mpiexec tries to exceed the procs-per-node that were given\n        # to the batch submission, things break. Setting MAX_TASKS_PER_NODE to half of\n        # it original value prevents this.\n        self._case.set_value(\"MAX_TASKS_PER_NODE\", int(self._case.get_value(\"MAX_TASKS_PER_NODE\") / 2))\n        self._case.set_value(\"MAX_MPITASKS_PER_NODE\", int(self._case.get_value(\"MAX_MPITASKS_PER_NODE\") / 2))\n\n        # Need to redo case_setup because we may have changed the number of threads\n        case_setup(self._case, reset=True)\n", "path": "scripts/lib/CIME/SystemTests/pet.py"}]}