Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ swell_static_files:

ioda_locations_not_in_r2d2:
default_value: /discover/nobackup/projects/gmao/dadev/rtodling/archive/542/prePP/ioda

scratch_root:
default_value: /discover/nobackup/projects/gmao/advda/TSE_staging
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ swell_static_files:

ioda_locations_not_in_r2d2:
default_value: /discover/nobackup/projects/gmao/dadev/rtodling/archive/542/prePP/ioda

scratch_root:
default_value: /discover/nobackup/projects/gmao/advda/TSE_staging
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import copy
import os
import yaml
from random import randint
from collections.abc import Mapping
from typing import Union, Tuple, Optional

Expand Down Expand Up @@ -334,6 +335,16 @@ def override_with_defaults(self) -> None:
if key == 'experiment_id' and val['default_value'] == 'defer_to_code':
val['default_value'] = f'swell-{self.suite}'

if key == 'scratch_id' and val['default_value'] == 'defer_to_code':
experiment_id = self.question_dictionary_model_ind['experiment_id']['default_value']
if experiment_id == 'defer_to_code':
experiment_id = f'swell-{self.suite}'
self.question_dictionary_model_ind['experiment_id'][
'default_value'] = experiment_id

scratch_id = f'{experiment_id}-{randint(0, 99999999):08d}'
val['default_value'] = scratch_id

# ----------------------------------------------------------------------------------------------

def override_with_external(self) -> None:
Expand Down
9 changes: 9 additions & 0 deletions src/swell/suites/3dfgat_atmos/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -185,4 +191,7 @@
script = "swell task CleanCycle $config -d $datetime -m {{model_component}}"
{% endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
10 changes: 10 additions & 0 deletions src/swell/suites/3dfgat_cycle/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
{% endfor %}
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -260,4 +267,7 @@
script = "swell task CleanCycle $config -d $datetime -m {{model_component}}"
{% endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
9 changes: 9 additions & 0 deletions src/swell/suites/3dvar/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -166,4 +172,7 @@
script = "swell task CleanCycle $config -d $datetime -m {{model_component}}"
{% endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
9 changes: 9 additions & 0 deletions src/swell/suites/3dvar_atmos/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -184,4 +190,7 @@
script = "swell task CleanCycle $config -d $datetime -m {{model_component}}"
{% endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
9 changes: 9 additions & 0 deletions src/swell/suites/3dvar_cycle/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
{% endfor %}
"""
{% endfor %}
{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -262,4 +268,7 @@
script = "swell task CleanCycle $config -d $datetime -m {{model_component}}"
{% endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
5 changes: 4 additions & 1 deletion src/swell/suites/build_geos/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
R1 = """
CloneGeos => BuildGeosByLinking?

BuildGeosByLinking:fail? => BuildGeos
BuildGeosByLinking:fail? => BuildGeos => CleanScratch
"""

# --------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -53,4 +53,7 @@
--{{key}} = {{value}}
{%- endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
5 changes: 4 additions & 1 deletion src/swell/suites/build_jedi/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
R1 = """
CloneJedi => BuildJediByLinking?

BuildJediByLinking:fail? => BuildJedi
BuildJediByLinking:fail? => BuildJedi => CleanScratch
"""

# --------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -53,4 +53,7 @@
--{{key}} = {{value}}
{%- endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
9 changes: 9 additions & 0 deletions src/swell/suites/convert_ncdiags/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -99,4 +105,7 @@
[[CleanCycle]]
script = "swell task CleanCycle $config -d $datetime -m geos_atmosphere"

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
9 changes: 9 additions & 0 deletions src/swell/suites/forecast_geos/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -113,4 +119,7 @@
--{{key}} = {{value}}
{%- endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
5 changes: 4 additions & 1 deletion src/swell/suites/geosadas/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
GetGeosAdasBackground => RunJediVariationalExecutable

# Clean cycle
RunJediVariationalExecutable => CleanCycle
RunJediVariationalExecutable => CleanCycle => CleanScratch
"""

# --------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -118,4 +118,7 @@
[[CleanCycle]]
script = "swell task CleanCycle $config -d $datetime -m geos_atmosphere"

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
9 changes: 9 additions & 0 deletions src/swell/suites/hofx/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -161,4 +167,7 @@
script = "swell task CleanCycle $config -d $datetime -m {{model_component}}"
{% endfor %}

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
8 changes: 6 additions & 2 deletions src/swell/suites/localensembleda/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
# RunJediLocalEnsembleDaExecutable-{{model_component}} => SaveObsDiags-{{model_component}}

# Clean up large files
# EvaObservations-{{model_component}} & SaveObsDiags-{{model_component}} &
EvaIncrement-{{model_component}} => CleanCycle-{{model_component}}
# EvaObservations-{{model_component}} & SaveObsDiags-{{model_component}} =>
EvaIncrement-{{model_component}} => CleanCycle-{{model_component}} => CleanScratch

{% endif %}
{% endfor %}
Expand Down Expand Up @@ -230,4 +230,8 @@

[[sync_point]]
script = true

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
5 changes: 4 additions & 1 deletion src/swell/suites/suite_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class SuiteQuestions(QuestionContainer, Enum):
qd.start_cycle_point(),
qd.final_cycle_point(),
qd.model_components(),
qd.runahead_limit()
qd.runahead_limit(),
qd.run_in_scratch(),
qd.scratch_root(),
qd.scratch_id(),
]
)

Expand Down
9 changes: 9 additions & 0 deletions src/swell/suites/ufo_testing/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
"""
{% endfor %}

{% for model_component in model_components %}
R1/$ = """
CleanCycle-{{model_component}} => CleanScratch
"""
{% endfor %}

# --------------------------------------------------------------------------------------------------

[runtime]
Expand Down Expand Up @@ -144,4 +150,7 @@
[[CleanCycle]]
script = "swell task CleanCycle $config -d $datetime -m geos_atmosphere"

[[CleanScratch]]
script = "swell task CleanScratch $config"

# --------------------------------------------------------------------------------------------------
25 changes: 22 additions & 3 deletions src/swell/tasks/base/task_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def __init__(
self.__platform__ = self.config.__platform__
self.__suite_to_run__ = self.config.__suite_to_run__

# Scratch directory information
# -----------------------------
self.__run_in_scratch__ = self.config.__run_in_scratch__(False)
self.__scratch_root__ = self.config.__scratch_root__(None)
self.__scratch_id__ = self.config.__scratch_id__(None)

if datetime_input is not None:
self.__start_cycle_point__ = Datetime(self.config.__start_cycle_point__)
self.__final_cycle_point__ = Datetime(self.config.__final_cycle_point__)
Expand Down Expand Up @@ -144,8 +150,15 @@ def experiment_id(self) -> str:
# ----------------------------------------------------------------------------------------------

# Method to get the experiment directory
def experiment_path(self) -> str:
return os.path.join(self.__experiment_root__, self.__experiment_id__)
def experiment_path(self, scratch: bool = True) -> str:
if self.__run_in_scratch__ and scratch:
print(self.__scratch_root__)
print(self.__scratch_id__)
experiment_path = os.path.join(self.__scratch_root__, self.__scratch_id__)
else:
experiment_path = os.path.join(self.__experiment_root__, self.__experiment_id__)

return experiment_path

# ----------------------------------------------------------------------------------------------

Expand All @@ -157,11 +170,17 @@ def platform(self) -> str:

# Method to get the experiment configuration directory
def experiment_config_path(self) -> str:
swell_exp_path = self.experiment_path()
swell_exp_path = self.experiment_path(scratch=False)
return os.path.join(swell_exp_path, 'configuration')

# ----------------------------------------------------------------------------------------------

def eva_config_path(self) -> str:
return os.path.join(self.experiment_path(scratch=False),
self.experiment_id()+'-suite', 'eva')

# ----------------------------------------------------------------------------------------------

def get_ensemble_packet(self) -> Optional[str]:
return self.__ensemble_packet__

Expand Down
Loading