Skip to content

Commit

Permalink
combined workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LucR31 committed Oct 27, 2023
1 parent 4484112 commit 9cc8385
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
28 changes: 22 additions & 6 deletions aiida_flexpart/workflows/multi_dates_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def define(cls, spec):
spec.expose_inputs(FlexpartCalculation,
include=['metadata.options'],
namespace='flexpart')
spec.expose_inputs(FlexpartIfsCalculation,
include=['metadata.options'],
namespace='flexpart')

# Outputs
#spec.output('output_file', valid_type=orm.SinglefileData)
Expand Down Expand Up @@ -121,6 +124,7 @@ def setup(self):
self.ctx.index = 0
self.ctx.simulation_dates = self.inputs.simulation_dates
self.ctx.integration_time = self.inputs.integration_time
self.ctx.offline_integration_time = self.inputs.offline_integration_time

#model settings
self.ctx.release_settings = self.inputs.release_settings
Expand Down Expand Up @@ -150,7 +154,13 @@ def prepare_meteo_folder_ifs(self):
'edate': orm.Str(e_date),
})

return node.is_finished_ok
if node.is_finished_ok:
self.report('meteo files transferred successfully')
return True
else:
self.report('failed to transfer meteo files')
self.ctx.index += 1
return False

def prepare_meteo_folder_cosmo(self):
e_date, s_date = get_simulation_period(self.ctx.simulation_dates[self.ctx.index],
Expand All @@ -170,7 +180,13 @@ def prepare_meteo_folder_cosmo(self):
'model': self.inputs.model
})

return node.is_finished_ok
if node.is_finished_ok:
self.report('meteo files transferred successfully')
return True
else:
self.report('failed to transfer meteo files')
self.ctx.index += 1
return False

def run_cosmo_simulation(self):
"""Run calculations for equation of state."""
Expand Down Expand Up @@ -216,14 +232,14 @@ def run_ifs_simulation(self):
# Set up calculation.
self.report(f'Running FIFS for {self.ctx.simulation_dates[self.ctx.index]}')
builder = FlexpartIfsCalculation.get_builder()
builder.code = self.inputs.ifs_code
builder.code = self.inputs.fifs_code

#changes in the command file
new_dict = self.ctx.command.get_dict()
new_dict['simulation_date'] = self.ctx.simulation_dates[self.ctx.index]
new_dict['dumped_particle_data'] = True
if self.ctx.offline_integration_time>0:
new_dict['age_class'] = self.ctx.offline_integration_time * 3600
new_dict['dumped_particle_data'] = True
else:
new_dict['age_class'] = self.inputs.integration_time * 3600
new_dict.update(self.inputs.meteo_inputs)
Expand All @@ -239,12 +255,12 @@ def run_ifs_simulation(self):
builder.outgrid = self.ctx.outgrid
builder.outgrid_nest = self.ctx.outgrid_nest
builder.species = self.ctx.species
builder.land_use = self.ctx.land_use_ifs
builder.land_use = self.inputs.land_use_ifs
builder.meteo_path = self.inputs.meteo_path_ifs

#remote folder from cosmo calc
if 'parent_calc_folder' in self.inputs:
builder.parent_calc_folder = self.ctx.parent_calc_folder
builder.parent_calc_folder = self.inputs.parent_calc_folder

# Walltime, memory, and resources.
builder.metadata.description = 'Test workflow to submit a flexpart calculation'
Expand Down
1 change: 1 addition & 0 deletions examples/example_ifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_run(flexpart_code):
'target_base': f'/store/empa/em05/{user_name}/aiida_stash',
'stash_mode': StashMode.COPY.value,
}
#builder.metadata.options.max_wallclock_seconds = 2000

# builder.metadata.dry_run = True
# builder.metadata.store_provenance = False
Expand Down
7 changes: 5 additions & 2 deletions examples/example_workflow_combi.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def simulation_dates_parser(date_list: list) -> list:
def test_run(flexpart_code):
"""Run workflow."""

simulation_dates = simulation_dates_parser(['2021-01-02'])
simulation_dates = simulation_dates_parser(['2021-01-03'])
username='lfernand'
users_address=f'/users/{username}/resources/flexpart/'
scratch_address=f'/scratch/snx3000/{username}/FLEXPART_input/'
Expand All @@ -81,6 +81,9 @@ def test_run(flexpart_code):
meteo_path_ifs = orm.RemoteData(
remote_path = scratch_address+'IFS_GL_05',
computer=flexpart_code.computer)
parent_folder = orm.RemoteData(
remote_path = scratch_address+'/',
computer=flexpart_code.computer)

#builder starts
workflow = plugins.WorkflowFactory('flexpart.multi_dates')
Expand Down Expand Up @@ -138,7 +141,7 @@ def test_run(flexpart_code):
'surfdata': surfdata,
'surfdepo': surfdepo,
}

#builder.parent_calc_folder = parent_folder
builder.flexpart.metadata.options.stash = {
'source_list': ['aiida.out', 'grid_time_*.nc'],
'target_base': f'/store/empa/em05/{username}/aiida_stash',
Expand Down
2 changes: 1 addition & 1 deletion examples/inputs/command.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concentration_output: 9 # Determines how the output shall be made: concentratio
# In plume trajectory mode, output is in the form of average trajectories.
particle_dump: 4 # Particle dump: 0 no, 1 every output interval, 2 only at end, 4 when leaving domain.
subgrid_terrain_effect_parameterization: True # Include ubgrid terrain effect parameterization.
convection_parametrization: 2 # Convection: 2 tiedtke, 1 emanuel, 0 no.
convection_parametrization: 1 # Convection: 2 tiedtke, 1 emanuel, 0 no.
age_spectra: True # Switch on/off the calculation of age spectra: if yes, the file AGECLASSES must be available.
dumped_particle_data: False # Continue simulation with dumped particle data.
output_for_each_release: True # Create an ouput file for each release location.
Expand Down

0 comments on commit 9cc8385

Please sign in to comment.