Skip to content

Commit

Permalink
Native EAMxx support
Browse files Browse the repository at this point in the history
Initial set of changes for ts and climo tasks to accept
native monthly EAMxx files as input. Supported by new
version of ncclimo.
  • Loading branch information
golaz authored and chengzhuzhang committed Feb 7, 2024
1 parent 3e796d3 commit 244d3b1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
4 changes: 2 additions & 2 deletions zppy/climo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def climo(config, scriptDir, existing_bundles, job_ids_file):
% (c["mapping_file"])
)

# Component
c["component"] = getComponent(c["input_files"])
# Output component (for directory structure) and procedure type for ncclimo
c["component"], c["prc_typ"] = getComponent(c["input_component"], c["input_files"])

# Loop over year sets
year_sets = getYears(c["years"])
Expand Down
15 changes: 8 additions & 7 deletions zppy/templates/climo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ cd ${workdir}

{% if frequency == 'monthly' %}
# --- Monthly climatologies ---
ncclimo \
/global/homes/z/zender/bin_perlmutter/ncclimo --npo \
{% if prc_typ == 'eamxx' -%}
--case={{ case }}.{{ input_files }}.0001-01-01-00000.nc \
--fml_nm={{ case }} \
{%- else -%}
--case={{ case }} \
{%- endif %}
--jobs=${SLURM_NNODES} \
--thr=1 \
{%- if exclude %}
Expand All @@ -47,11 +52,7 @@ ncclimo \
--output=trash \
--regrid=output \
{%- endif %}
{%- if input_files.split(".")[0] == 'cam' or input_files.split(".")[0] == 'eam' or input_files.split(".")[0] == 'elm' or input_files.split(".")[0] == 'clm2' %}
--prc_typ={{ input_files.split(".")[0] }}
{%- else -%}
--prc_typ=sgs
{%- endif %}
--prc_typ={{ prc_typ }}

{% elif frequency.startswith('diurnal') %}

Expand Down Expand Up @@ -97,7 +98,7 @@ if grep -q "*" input.txt; then
exit 1
fi
# Now, call ncclimo
cat input.txt | ncclimo \
cat input.txt | /global/homes/z/zender/bin_perlmutter/ncclimo --npo \
--case={{ case }}.{{ input_files }} \
--jobs=${SLURM_NNODES} \
--thr=1 \
Expand Down
6 changes: 6 additions & 0 deletions zppy/templates/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ parallel = string(default="mpi")
nodes = integer(default=4)
# NOTE: always overrides value in [default]
vars = string(default="")
# Model component having generated input files (eam, eamxx, elm, mosart, ...)
input_component = string(default="")

[[__many__]]
exclude = boolean(default=None)
nodes = integer(default=None)
vars = string(default=None)
input_component = string(default=None)

[ts]
area_nm = string(default="area")
Expand All @@ -93,6 +96,8 @@ extra_vars = string(default="")
# Time-steps per day
tpd = integer(default=1)
ts_fmt = string(default="ts_only")
# Model component having generated input files (eam, eamxx, elm, mosart, ...)
input_component = string(default="")

[[__many__]]
area_nm = string(default=None)
Expand All @@ -101,6 +106,7 @@ ts_fmt = string(default="ts_only")
extra_vars = string(default=None)
tpd = integer(default=None)
ts_fmt = string(default=None)
input_component = string(default=None)

[tc_analysis]
# NOTE: always overrides value in [default]
Expand Down
6 changes: 1 addition & 5 deletions zppy/templates/ts.bash
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ cat input.txt | ncclimo \
--dpf={{ dpf }} \
--tpd={{ tpd }} \
{%- endif %}
{%- if input_files.split(".")[0] == 'cam' or input_files.split(".")[0] == 'eam' or input_files.split(".")[0] == 'elm' or input_files.split(".")[0] == 'clm2' %}
--prc_typ={{ input_files.split(".")[0][:3] }}
{%- else %}
--prc_typ=sgs
{%- endif %}
--prc_typ={{ prc_typ }}
Expand Down
4 changes: 2 additions & 2 deletions zppy/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def ts(config, scriptDir, existing_bundles, job_ids_file):
% (c["mapping_file"])
)

# Component
c["component"] = getComponent(c["input_files"])
# Output component (for directory structure) and procedure type for ncclimo
c["component"], c["prc_typ"] = getComponent(c["input_component"], c["input_files"])

c["cmor_tables_prefix"] = c["diagnostics_base_path"]

Expand Down
22 changes: 16 additions & 6 deletions zppy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,36 @@ def getYears(years_list):


# -----------------------------------------------------------------------------
# Return component name from input files (e.g. 'cam.h0', 'clm2.h0', ...)
# Return output component name and procedure type based on either
# input_component or input_files

def getComponent(input_component, input_files):

def getComponent(input_files):
if input_component != '':
tmp = input_component
else:
tmp = input_files.split(".")[0]

# Default ncclim procedure type is "sgs"
prc_typ = "sgs"

tmp = input_files.split(".")[0]
if tmp in ("cam", "eam"):
# Output component (for directory structure) and ncclimo procedure type
if tmp in ("cam", "eam", "eamxx"):
component = "atm"
prc_typ = tmp
elif tmp in ("cpl",):
component = "cpl"
elif tmp in ("clm2", "elm"):
component = "lnd"
prc_typ = tmp
elif tmp in ("mosart",):
component = "rof"
else:
raise ValueError(
"Cannot extract component name from input_files %s" % (input_files)
"Cannot extract output component name from input_component or input_files %s" % (input_component,input_files)
)

return component
return component, prc_typ


# -----------------------------------------------------------------------------
Expand Down

0 comments on commit 244d3b1

Please sign in to comment.