From 15a79e50869876727ade9badd478b101b07a6f3a Mon Sep 17 00:00:00 2001 From: LucR31 Date: Fri, 20 Oct 2023 13:48:57 +0000 Subject: [PATCH] added previous calc folder for ifs --- aiida_flexpart/calculations/flexpart_ifs.py | 13 +++++++++---- aiida_flexpart/utils.py | 8 +++++++- examples/example_ifs.py | 8 ++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/aiida_flexpart/calculations/flexpart_ifs.py b/aiida_flexpart/calculations/flexpart_ifs.py index e491071..106006f 100644 --- a/aiida_flexpart/calculations/flexpart_ifs.py +++ b/aiida_flexpart/calculations/flexpart_ifs.py @@ -164,12 +164,17 @@ def prepare_for_submission(self, folder): 'SPECIES' )) - #_DEFAULT_PARENT_CALC_FLDR_NAME = "parent_calc/" if "parent_calc_folder" in self.inputs: + computer_uuid = self.inputs.parent_calc_folder.computer.uuid + remote_path = self.inputs.parent_calc_folder.get_remote_path() calcinfo.remote_symlink_list.append(( - self.inputs.parent_calc_folder.computer.uuid, - self.inputs.parent_calc_folder.get_remote_path(), - self._DEFAULT_PARENT_CALC_FLDR_NAME)) + computer_uuid, + remote_path+'/header', + 'header_previous')) + calcinfo.remote_symlink_list.append(( + computer_uuid, + remote_path+'/partposit_inst', + 'partposit_previous')) # Dealing with land_use input namespace. diff --git a/aiida_flexpart/utils.py b/aiida_flexpart/utils.py index 5371920..ef04241 100644 --- a/aiida_flexpart/utils.py +++ b/aiida_flexpart/utils.py @@ -176,7 +176,13 @@ def convert_input_to_namelist_entry(key, val, mapping=None): def fill_in_template_file(folder, fname, data): """Create an input file based on the standard templates.""" - with folder.open(fname, 'w') as infile: + + if 'ifs' in fname: + fname_=fname[:-4] + else: + fname_=fname + + with folder.open(fname_, 'w') as infile: template = jinja2.Template( importlib.resources.read_text('aiida_flexpart.templates', fname + '.j2')) diff --git a/examples/example_ifs.py b/examples/example_ifs.py index 9a32fc6..eb128ae 100644 --- a/examples/example_ifs.py +++ b/examples/example_ifs.py @@ -59,6 +59,11 @@ def test_run(flexpart_code): meteo_path = orm.RemoteData( remote_path=f'/scratch/snx3000/{user_name}/FLEXPART_input/IFS_GL_05', computer=flexpart_code.computer) + + #change path accordingly + previous_cosmo_calc = orm.RemoteData( + remote_path=f'/scratch/snx3000/{user_name}/aiida/9e/2c/5188-d166-4b20-a89f-b2559a83a6b1', + computer=flexpart_code.computer) # Set up calculation. calc = CalculationFactory('flexpart.ifs') @@ -82,6 +87,9 @@ def test_run(flexpart_code): 'surfdepo': surfdepo, } + #uncomment to use previous cosmo calculation + #builder.parent_calc_folder = previous_cosmo_calc + builder.metadata.description = 'Test job submission with the aiida_flexpart plugin' builder.metadata.options.stash = { 'source_list': ['aiida.out', 'grid_time_*.nc'],