diff --git a/arc/job/adapters/molpro.py b/arc/job/adapters/molpro.py index 218e98f593..cb47c95a83 100644 --- a/arc/job/adapters/molpro.py +++ b/arc/job/adapters/molpro.py @@ -357,13 +357,13 @@ def set_input_file_memory(self) -> None: if available_cores < current_cpu_cores: self.cpu_cores = available_cores logger.info(f'Changing the number of cpu_cores from {current_cpu_cores} to {self.cpu_cores}') - # Situation may occur when the required memory per process by Molpro is only enough for 1 cpu core for us to use (for example, 4300 MW -> 32.04GB and if we have 64GB, we can only use 1 cpu core) - # And this means that for 1 CPU, we may end up using all 64GB of memory which approximates to 8600 MW. We need to take precaution here and not use all the memory. - # We will therefore, limit the MW to 4300 MW - self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores)) - if self.cpu_cores == 1 and self.input_file_memory > min_memory_value: - self.input_file_memory = min_memory_value - logger.info(f'Changing the input_file_memory from {self.input_file_memory} to {min_memory_value} as the number of cpu_cores will be restricted to 1 due to the memory requirements of Molpro') + # Situation may occur when the required memory per process by Molpro is only enough for 1 cpu core for us to use (for example, 4300 MW -> 32.04GB and if we have 64GB, we can only use 1 cpu core) + # And this means that for 1 CPU, we may end up using all 64GB of memory which approximates to 8600 MW. We need to take precaution here and not use all the memory. + # We will therefore, limit the MW to 4300 MW + self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores)) + if self.cpu_cores == 1 and self.input_file_memory > min_memory_value: + self.input_file_memory = min_memory_value + logger.info(f'Changing the input_file_memory from {self.input_file_memory} to {min_memory_value} as the number of cpu_cores will be restricted to 1 due to the memory requirements of Molpro') def execute_incore(self): """ diff --git a/arc/job/adapters/molpro_test.py b/arc/job/adapters/molpro_test.py index 42cc640c7d..0a15bd8556 100644 --- a/arc/job/adapters/molpro_test.py +++ b/arc/job/adapters/molpro_test.py @@ -64,6 +64,17 @@ def setUpClass(cls): job_memory_gb=64, ) + cls.job_5 = MolproAdapter(execution_type='queue', + job_type='opt', + level=Level(method='CCSD(T)', basis='cc-pVQZ'), + project='test', + project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_MolproAdapter_2'), + species=[ARCSpecies(label='spc1', xyz=['O 0 0 1'])], + testing=True, + ess_trsh_methods=['memory','cpu', 'molpro_memory: 2800 '], + job_memory_gb=64, + ) + def test_set_cpu_and_mem(self): """Test assigning number of cpu's and memory""" self.job_1.cpu_cores = 48 @@ -84,7 +95,6 @@ def test_memory_change(self): self.assertEqual(self.job_4.input_file_memory, 4300) self.assertEqual(self.job_4.cpu_cores, 1) - def test_set_input_file_memory(self): """Test setting the input_file_memory argument""" self.job_1.input_file_memory = None @@ -165,6 +175,15 @@ def test_write_input_file(self): """ self.assertEqual(content_2, job_2_expected_input_file) + def test_core_reduction_logic(self): + """Test the core reduction logic""" + + # Job 5 again to trigger the condition of the core reduction logic + # Job 5 technically would be 3 CPUs prior to the reactive setting the input file memory. + self.job_5.set_input_file_memory() + self.assertEqual(self.job_5.input_file_memory, 4296) + self.assertEqual(self.job_5.cpu_cores, 2) + def test_set_files(self): """Test setting files""" job_1_files_to_upload = [{'file_name': 'submit.sub',