Skip to content

Commit 04a0b5a

Browse files
authored
Base namelist dimension names on corresponding variable name (#437)
Tag name (required for release branches): Originator(s): @nusbaume Description (include the issue title, and the keyword ['closes', 'fixes', 'resolves'] followed by the issue number): This PR changes how the standard name for a namelist variable dimension is generated, with the standard name now based off the corresponding namelist variable name, plus an additional numerical suffix included for any additional dimensions needed for that particular namelist variable. This PR also makes all namelist variable dimensions public, and thus directly accessible by CCPP-ized physics schemes. Fixes #436 Describe any changes made to build system: M cime_config/create_readnl_files.py - Change namelist variable dimension naming convention, and make all dimensions public. Also update doctests. Describe any changes made to the namelist: N/A List any changes to the defaults for the input datasets (e.g. boundary datasets): N/A List all files eliminated and why: N/A List all files added and what they do: N/A List all existing files that have been modified, and describe the changes: (Helpful git command: `git diff --name-status development...<your_branch_name>`) M test/unit/python/sample_files/namelist_files/kumquat_namelist.F90 M test/unit/python/sample_files/namelist_files/kumquat_namelist.meta - Update unit test files to expect new namelist variable dimension standard names and Fortran declarations. M .lib/git-fleximod/README.md M .lib/git-fleximod/git_fleximod/cli.py M .lib/git-fleximod/git_fleximod/submodule.py M .lib/git-fleximod/pyproject.toml M .lib/git-fleximod/tbump.toml - Update git-fleximod to version 1.0.3 M .github/workflows/branch_push_workflow.yml M .github/workflows/fleximod_test.yaml M .github/workflows/python_unit_tests.yml M .github/workflows/source_code_lint.yml - Update checkout and setup-python to versions 5 and 6, respectively. If there are new failures (compared to the `test/existing-test-failures.txt` file), have them OK'd by the gatekeeper, note them here, and add them to the file. If there are baseline differences, include the test and the reason for the diff. What is the nature of the change? Roundoff? derecho/intel/aux_sima: No new test failures (only expected multitape failure) derecho/gnu/aux_sima: ALL PASS If this changes climate describe any run(s) done to evaluate the new climate in enough detail that it(they) could be reproduced: CAM-SIMA date used for the baseline comparison tests if different than latest:
1 parent 1bdc129 commit 04a0b5a

File tree

12 files changed

+50
-34
lines changed

12 files changed

+50
-34
lines changed

.github/workflows/branch_push_workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
# Acquire github action routines
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v5
2424
# Acquire specific version of python
2525
- name: Set up Python 3.11
26-
uses: actions/setup-python@v5
26+
uses: actions/setup-python@v6
2727
with:
2828
python-version: '3.11' # Semantic version range syntax or exact version of a Python version
2929
# Install required python packages

.github/workflows/fleximod_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
python-version: ["3.8", "3.x"]
1111
steps:
1212
- id: checkout-CESM
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414
- id: run-fleximod
1515
run: |
1616
$GITHUB_WORKSPACE/bin/git-fleximod update -o

.github/workflows/python_unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
fail-fast: false
2727
steps:
2828
# Acquire github action routines:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v5
3030
# Acquire specific version of python:
3131
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v4
32+
uses: actions/setup-python@v6
3333
with:
3434
python-version: ${{ matrix.python-version }}
3535
# Install xmllint so tests pass:

.github/workflows/source_code_lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
# acquire github action routines
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v5
1818
# acquire specific version of python
1919
- name: Set up Python 3.10
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v6
2121
with:
2222
python-version: "3.10" # Use python 3.10
2323
# install required python packages

.lib/git-fleximod/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Git-fleximod is a Python-based tool that extends Git's submodule and sparse chec
2525

2626
## Supported .gitmodules Variables
2727

28-
fxtag: Specify a specific tag or branch to checkout for a submodule.
28+
fxtag: Specify a specific tag or hash to checkout for a submodule. Branches are not acceptable.
2929
fxrequired: Mark a submodule's checkout behavior, with allowed values:
3030
- ToplevelRequired: Top-level and required (checked out only when this is the Toplevel module).
3131
- ToplevelOptional: Top-level and optional (checked out with --optional flag if this is the Toplevel module).

.lib/git-fleximod/git_fleximod/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import argparse, os, sys
33
from git_fleximod import utils
44

5-
__version__ = "1.0.2"
5+
__version__ = "1.0.3"
66

77
class CustomArgumentParser(argparse.ArgumentParser):
88
def print_help(self, file=None):

.lib/git-fleximod/git_fleximod/submodule.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ async def update(self):
400400
# This is a tag
401401
tag = f"refs/tags/{self.fxtag}:refs/tags/{self.fxtag}"
402402
status,_ = smgit.git_operation("fetch", newremote, tag)
403+
else:
404+
# This is likely a hash, so fetch full history just in case
405+
status,_ = smgit.git_operation("fetch", newremote)
403406
if status == 0:
404407
status,_ = smgit.git_operation("checkout", self.fxtag)
405408
if status:

.lib/git-fleximod/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "git-fleximod"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
description = "Extended support for git-submodule and git-sparse-checkout"
55
authors = ["Jim Edwards <[email protected]>"]
66
maintainers = ["Jim Edwards <[email protected]>"]

.lib/git-fleximod/tbump.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
github_url = "https://github.com/jedwards4b/git-fleximod/"
33

44
[version]
5-
current = "1.0.2"
5+
current = "1.0.3"
66

77
# Example of a semver regexp.
88
# Make sure this matches current_version before

cime_config/create_readnl_files.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class NLVar:
160160
"""Class to hold information about a namelist variable entry"""
161161

162162
# For unique dimension names
163-
__new_dim_suffix = 0
163+
__new_dim_suffix = {}
164164

165165
# For validity error messages
166166
__kind_errstr = "Conflicting kind arguments, '{}' and '{}' for '{}'"
@@ -327,9 +327,9 @@ def _parse_array_desc(cls, alen, name):
327327
should have been sanitized by _parse_xml_type.
328328
329329
>>> NLVar._parse_array_desc("10", "foo")
330-
((10,), ('cam_nl_autogen1_dimension',))
330+
((10,), ('foo_dimension',))
331331
>>> NLVar._parse_array_desc("15,3", "bar")
332-
((15, 3), ('cam_nl_autogen2_dimension', 'cam_nl_autogen3_dimension'))
332+
((15, 3), ('bar_dimension', 'bar_dimension_2'))
333333
>>> NLVar._parse_array_desc("15,,3", "foobar")
334334
Traceback (most recent call last):
335335
...
@@ -338,7 +338,7 @@ def _parse_array_desc(cls, alen, name):
338338
if alen:
339339
try:
340340
alens = tuple([int(x.strip()) for x in alen.split(',')])
341-
anames = tuple([cls._new_nl_dimname() for x in alens])
341+
anames = tuple([cls._new_nl_dimname(name) for x in alens])
342342
except:
343343
emsg = f"Invalid array argument, '{alen}', for {name}"
344344
raise ParseInternalError(emsg)
@@ -462,10 +462,23 @@ def write_decl(self, file, indent, intent=None):
462462
file.write(decl, indent)
463463

464464
@classmethod
465-
def _new_nl_dimname(cls):
465+
def _new_nl_dimname(cls, var_name):
466466
"""Return a new dimension name for use with a namelist array variable"""
467-
cls.__new_dim_suffix += 1
468-
return f"cam_nl_autogen{cls.__new_dim_suffix}_dimension"
467+
468+
# Update number of dimensions for the
469+
# specified namelist variable:
470+
if var_name in cls.__new_dim_suffix:
471+
cls.__new_dim_suffix[var_name] += 1
472+
else:
473+
cls.__new_dim_suffix[var_name] = 1
474+
475+
# Create new dimension name based
476+
# on the variable name and number of
477+
# variable dimensions:
478+
if cls.__new_dim_suffix[var_name] > 1:
479+
return f"{var_name}_dimension_{cls.__new_dim_suffix[var_name]}"
480+
else:
481+
return f"{var_name}_dimension"
469482

470483
def var_mpi_type(self):
471484
"""Return the MPI variable type constant of this NLVar object.
@@ -483,7 +496,7 @@ def write_dimension_decls(self, ofile, indent):
483496
"""
484497
for index, alen in enumerate(self.array_len):
485498
aname = self.__array_names[index]
486-
ofile.write(f"integer, parameter :: {aname} = {alen}", indent)
499+
ofile.write(f"integer, public, parameter :: {aname} = {alen}", indent)
487500
# end for
488501

489502
@property

0 commit comments

Comments
 (0)