diff --git a/aiida_flexpart/calculations/flexpart_cosmo.py b/aiida_flexpart/calculations/flexpart_cosmo.py index 494d192..188d880 100644 --- a/aiida_flexpart/calculations/flexpart_cosmo.py +++ b/aiida_flexpart/calculations/flexpart_cosmo.py @@ -51,7 +51,7 @@ def define(cls, spec): help='Input file for the Lagrangian particle dispersion model FLEXPART. Nested output grid.' ) spec.input('species', valid_type=orm.RemoteData, required=True) - spec.input('meteo_path', valid_type=orm.RemoteData, + spec.input('meteo_path', valid_type=orm.List, required=True, help='Path to the folder containing the meteorological input data.') spec.input('metadata.options.output_filename', valid_type=str, default='aiida.out', required=True) spec.input_namespace('land_use', valid_type=orm.RemoteData, required=False, dynamic=True, help='#TODO') @@ -62,13 +62,13 @@ def define(cls, spec): @classmethod def _deal_with_time(cls, command_dict): """Dealing with simulation times.""" - + #initial values simulation_beginning_date = datetime.datetime.strptime(command_dict.pop('simulation_date'),'%Y-%m-%d %H:%M:%S') age_class_time = datetime.timedelta(seconds=command_dict.pop('age_class')) release_chunk = datetime.timedelta(seconds=command_dict.pop('release_chunk')) release_duration = datetime.timedelta(seconds=command_dict.pop('release_duration')) - + #releases start and end times release_beginning_date=simulation_beginning_date release_ending_date=release_beginning_date+release_duration @@ -76,8 +76,8 @@ def _deal_with_time(cls, command_dict): if command_dict['simulation_direction']>0: #forward simulation_ending_date=release_ending_date+age_class_time else: #backward - simulation_ending_date=release_ending_date - simulation_beginning_date-=age_class_time + simulation_ending_date=release_ending_date + simulation_beginning_date-=age_class_time command_dict['simulation_beginning_date'] = [ f'{simulation_beginning_date:%Y%m%d}', @@ -101,16 +101,13 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-locals needed by the calculation. :return: `aiida.common.datastructures.CalcInfo` instance """ + meteo_string_list = ['./','./'] + for path in self.inputs.meteo_path: + meteo_string_list.append(f'{path}{os.sep}') + meteo_string_list.append(f'{path}/AVAILABLE') - meteo_path = pathlib.Path(self.inputs.meteo_path.get_remote_path()) codeinfo = datastructures.CodeInfo() - codeinfo.cmdline_params = [ - './', # Folder containing the inputs. - './', # Folder containing the outputs. - f'{meteo_path}{os.sep}', - str(meteo_path / 'AVAILABLE'), - # File that lists all the individual input files that are available and assigns them a date - ] + codeinfo.cmdline_params = meteo_string_list codeinfo.code_uuid = self.inputs.code.uuid codeinfo.stdout_name = self.metadata.options.output_filename codeinfo.withmpi = self.inputs.metadata.options.withmpi diff --git a/aiida_flexpart/parsers/flexpart_cosmo.py b/aiida_flexpart/parsers/flexpart_cosmo.py index c9a4653..ed8c81a 100644 --- a/aiida_flexpart/parsers/flexpart_cosmo.py +++ b/aiida_flexpart/parsers/flexpart_cosmo.py @@ -47,15 +47,13 @@ def parse(self, **kwargs): files_retrieved, files_expected)) return self.exit_codes.ERROR_MISSING_OUTPUT_FILES - # check aiida.out content + # add output file + self.logger.info(f"Parsing '{output_filename}'") with self.retrieved.open(output_filename, 'r') as handle: - content=handle.read() + output_node = SinglefileData(file=handle) + self.out('output_file', output_node) + content = handle.read() if 'CONGRATULATIONS' not in content: return ExitCode(1) - # add output file - self.logger.info("Parsing '{}'".format(output_filename)) - with self.retrieved.open(output_filename, 'rb') as handle: - output_node = SinglefileData(file=handle) - self.out('output_file', output_node) return ExitCode(0)