Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rocoto sh tag, script to check netcdf file and apply this to check ocean output #2484

Merged
merged 8 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Empty file modified ush/bash_utils.sh
100644 → 100755
Empty file.
14 changes: 14 additions & 0 deletions ush/check_netcdf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/env bash

HOMEgfs=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P)
Fixed Show fixed Hide fixed
declare -rx HOMEgfs

source "${HOMEgfs}/ush/load_fv3gfs_modules.sh" 1>/dev/null 2>&1

ncfile=${1?}

ncdump -h "${ncfile}"
rc=$?
# If there is no error, rc=0, else rc!=0

exit "${rc}"
Empty file modified ush/file_utils.sh
100644 → 100755
Empty file.
Empty file modified ush/jjob_header.sh
100644 → 100755
Empty file.
Empty file modified ush/preamble.sh
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion workflow/rocoto/gfs_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,11 @@ def _atmosoceaniceprod(self, component: str):
data = f'{history_path}/{history_file_tmpl}'
dep_dict = {'type': 'data', 'data': data, 'age': 120}
deps.append(rocoto.add_dependency(dep_dict))
dependencies = rocoto.create_dependency(dep=deps)
if component in ['ocean']:
command = f"{self.HOMEgfs}/ush/check_netcdf.sh {history_path}/{history_file_tmpl}"
dep_dict = {'type': 'sh', 'command': command}
deps.append(rocoto.add_dependency(dep_dict))
dependencies = rocoto.create_dependency(dep=deps, dep_condition='and')
cycledef = 'gdas_half,gdas' if self.cdump in ['gdas'] else self.cdump
resources = self.get_resource(component_dict['config'])

Expand Down
29 changes: 28 additions & 1 deletion workflow/rocoto/rocoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

ABOUT:
Helper module to create tasks, metatasks, and dependencies for Rocoto
Rocoto documentation is available at https://christopherwharrop.github.io/rocoto
'''

__all__ = ['create_task',
Expand Down Expand Up @@ -182,7 +183,8 @@ def add_dependency(dep_dict: Dict[str, Any]) -> str:
'data': _add_data_tag,
'cycleexist': _add_cycle_tag,
'streq': _add_streq_tag,
'strneq': _add_streq_tag}
'strneq': _add_streq_tag,
'sh': _add_sh_tag}

dep_condition = dep_dict.get('condition', None)
dep_type = dep_dict.get('type', None)
Expand Down Expand Up @@ -333,6 +335,31 @@ def _add_streq_tag(dep_dict: Dict[str, Any]) -> str:
return string


def _add_sh_tag(dep_dict: Dict[str, Any]) -> str:
"""
create a simple shell execution tag
:param: dep_dict: shell command to execute
:type dep_dict: dict
:return: Rocoto simple shell execution dependency
:rtype: str
"""

shell = dep_dict.get('shell', '/bin/sh')
WalterKolczynski-NOAA marked this conversation as resolved.
Show resolved Hide resolved
command = dep_dict.get('command', 'echo "Hello World"')

if '@' in command:
offset_string_b = f'<cyclestr>'
offset_string_e = '</cyclestr>'
else:
offset_string_b = ''
offset_string_e = ''
cmd = f'{offset_string_b}{command}{offset_string_e}'

string = f'<sh shell="{shell}">{cmd}</sh>'

return string


def _traverse(o, tree_types=(list, tuple)):
"""
Traverse through a list of lists or tuples and yield the value
Expand Down
Loading