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
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Note that submodules should be automatically excluded.
exclude: bin/git-fleximod, .lib/git_fleximod*, tools/contrib/.*

repos:

# Various useful checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:

# Makes sure files end in a newline and only a newline.
- id: end-of-file-fixer
files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml

- id: check-yaml
files: / python/ lilac/ .github/

- id: check-xml

# Check for debugger imports and py37+ breakpoint() calls in python source
- id: debug-statements
files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml

# Checks files for mixed line endings. By default, standardizes to the most common ending.
- id: mixed-line-ending
files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml

# Prevent giant files from being committed. Default "too large" is 500KB.
# git-lfs files will be skipped if it is installed.
- id: check-added-large-files

# These two showed lot's of issues so should be worked on before turning on
#- id: check-executables-have-shebangs
# exclude: shell_commands
#- id: check-shebang-scripts-are-executable
# exclude: shell_commands

# Checks for a common error of placing code before the docstring.
- id: check-docstring-first
files: python/ cime_config/SystemTests/ cime_config/buildlib cime_config/buildnml

# Run black formatter
- repo: https://github.com/psf/black
rev: 25.1.0 # Keep this synced with version in python/conda_env_ctsm_py.yml
hooks:
- id: black
args: [--config, python/pyproject.toml]
language_version: python3.13.2
files: >-
(?x)(
python/.*\.py
cime_config/SystemTests|
cime_config/buildlib|
cime_config/buildnml|
)
38 changes: 35 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,48 @@ https://groups.google.com/a/ucar.edu/forum/#!forum/ctsm-dev

Use the help from the wiki below to setup a fork and personal branch in GitHub to put your developments
on and keep up to date with the master branch of CTSM. Once the changes are sufficiently advanced you
can form a Pull Request on GitHub. Either from your fork on GitHub, or from the main ESCOMP GitHub page
can form a Pull Request (PR) on GitHub. Either from your fork on GitHub, or from the main ESCOMP GitHub page
for CTSM (be sure to hit the "compare across forks" link at the top of the page when you first create
the pull request).

https://github.com/ESCOMP/ctsm/pulls

This allows you to show your proposed changes and start getting feedback on them (even if they aren't finished).
This also allows your changes to be planned for and slated for a time to come into CTSM master. In most
cases you won't merge the Pull Request yourself, but a software engineer responsible for CTSM will do
additional testing and bring the changes to CTSM master.
cases you won't merge the PR yourself, but a software engineer responsible for CTSM will do
additional testing and bring the changes to CTSM maste

In summary:

- [ ] Create an issue on what you propose to do
- [ ] Join [email protected] group
- [ ] Setup a fork and branch to do your work
- [ ] Setup pre-commit (see below)
- [ ] Get help and examine the CTSM resources below
- [ ] Open a PR when the work is started so that we can give helpful advice on it
- [ ] Run standard testing for your changes
- [ ] Have the PR reviewed and priority evaluated
- [ ] The CTSM SE team will bring it in and merge to main development

## Running pre-commit and python testing

We are using some formatters and code checkers to ensure the code is in reasonable shape when committed. You need to hae the ctsm_pylib to run these. The steps to do that are:

Installing pre-commit:

``` shell
./py_env_create
pre-commit install
```

Running python tests:

``` shell
./py_en_create
cd python
make all
./run_ctsm_py_tests --sys
Copy link
Member

@samsrabin samsrabin Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, this will fail on systems other than Derecho. It's also incomplete, because the Python testing also requires the clm_pymods suite. I'd suggest just not including the bit about Python testing, since we have instructions for that elsewhere. Instead, here just explain how to install pre-commit. But also, instructions should be added (or a link provided) that explains how to use pre-commit.

```

### CTSM Developers Guide:

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3739617.svg)](https://doi.org/10.5281/zenodo.3739617)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
## Overview and resources

The Community Terrestrial Systems Model.
Expand Down
4 changes: 3 additions & 1 deletion bld/namelist_files/namelist_definition.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@
<xsl:apply-templates select="entry[@category='mkgriddata']"/>
</table>
<table border="1" cellpadding="10">
<table border="1" cellpadding="10">
<caption>CLM mkgriddata</caption>
<tr>
<th rowspan="2">Name</th>
Expand Down Expand Up @@ -323,6 +322,9 @@
<hr/>

</body>



</xsl:template>

<xsl:template match="entry">
Expand Down
6 changes: 6 additions & 0 deletions python/conda_env_ctsm_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ dependencies:
- matplotlib=3.10.1
- pip=25.0.1

# For running pre-commit hooks
- pre-commit=4.2.0

# For using fortls (Fortran Language Server) with VS Code
- fortls=3.2.2

# For building docs
- pip:
- -r ../doc/ctsm-docs_container/requirements.txt
Expand Down
Loading