Skip to content

Commit

Permalink
Merge pull request #340 from earth-system-radiation/develop
Browse files Browse the repository at this point in the history
Minor updates - c_bool always, more CI, code formatting and pre-commit.
  • Loading branch information
skosukhin authored Jan 14, 2025
2 parents 2c4a848 + 9507fea commit fbf5f5e
Show file tree
Hide file tree
Showing 82 changed files with 1,429 additions and 1,292 deletions.
6 changes: 3 additions & 3 deletions .cmake-format.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
with section("parse"):
with section("parse"): # noqa: F821
additional_commands = {"check_python3_package": {"pargs": 1, "kwargs": {"CODE": 1}}}

with section("format"):
with section("format"): # noqa: F821
dangle_parens = True
max_lines_hwrap = 0
keyword_case = "upper"
autosort = True

with section("lint"):
with section("lint"): # noqa: F821
# The formatter sometimes fails to fit the code into the line limit (C0301) and can
# disagree with the linter regarding the indentation (C0307):
disabled_codes = ["C0301", "C0307"]
Expand Down
6 changes: 4 additions & 2 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Formatted entire CMake code base with cmake-format
45b43632309cff022326472a8be0fdd5efc8f5c8
# Formatted entire codebase (#337)
db7044f9c85b9675b0447d2162001f32b61e0e84
cc0f75b44d536fd10fa0556474926e58bfbb3f4f
71520f8bcc8af9611e2a0f70eb3278fcc3064343
2 changes: 1 addition & 1 deletion .github/workflows/check-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
$FC --version
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DKERNEL_MODE=$RTE_KERNELS
-DKERNEL_MODE="$RTE_KERNELS"
cmake --build build
2 changes: 1 addition & 1 deletion .github/workflows/containerized-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
run: |
cmake -S . -B build -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DRTE_ENABLE_SP=`test 'x${{ matrix.fpmodel }}' = xSP && echo ON || echo OFF` \
-DRTE_ENABLE_SP="$(test '${{ matrix.fpmodel }}' = SP && echo ON || echo OFF)" \
-DKERNEL_MODE=${{ matrix.rte-kernels }} \
-DBUILD_TESTING=ON
cmake --build build
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
gfortran-version: [12, 13, 14]
gfortran-from: [system, conda]
fpmodel: [DP, SP]
exclude:
exclude:
- os: ubuntu-24.04
gfortran-from: conda
- os: macos-13
Expand All @@ -38,7 +38,7 @@ jobs:
gfortran-version: 14
gfortran-from: conda
- os: windows-2022
include:
include:
- os: ubuntu-24.04
gfortran-version: 13
gfortran-from: conda
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
if: matrix.gfortran-from == 'conda'
run: |
conda install -c conda-forge gfortran=${{ matrix.gfortran-version }} -y
echo "FC=gfortran" >> $GITHUB_ENV
echo "FC=gfortran" >> "$GITHUB_ENV"
#
# Install dependencies
#
Expand All @@ -112,15 +112,15 @@ jobs:
#
- name: Adjust toolchain
if: matrix.os == 'windows-2022'
run: echo "FC=${FC}.exe" >> $GITHUB_ENV
run: echo "FC=${FC}.exe" >> "$GITHUB_ENV"
#
# Build libraries, examples, and tests
#
- name: Build libraries and tests
run: |
cmake -S . -B build -G "Ninja" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DRTE_ENABLE_SP=`test 'x${{ matrix.fpmodel }}' = xSP && echo ON || echo OFF` \
-DRTE_ENABLE_SP="$(test '${{ matrix.fpmodel }}' = SP && echo ON || echo OFF)" \
-DBUILD_TESTING=ON
cmake --build build
#
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
#
lumi-init:
if: |
false &&
false &&
github.repository_owner == 'earth-system-radiation' &&
( github.event_name != 'pull_request' ||
( github.event.pull_request.head.repo.owner.login == github.repository_owner &&
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/module_switcher
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,3 @@ switch_for_module ()
eval "$sfm_cmd"
done
}

57 changes: 4 additions & 53 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,15 @@ on:
- documentation
workflow_dispatch:

env:
FIND_CMAKE_FILES_CMD: "find '${{ github.workspace }}' -name 'CMakeLists.txt' -o -name '*.cmake' -o -name '*.cmake.in'"

jobs:
Format:
runs-on: ubuntu-22.04
env:
DEFAULT: '\033[0m'
RED: '\033[0;31m'
GREEN: '\033[0;32m'
FORMAT_PATCH: '${{ github.workspace }}/format.patch'
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '>=3.8'
- name: Install required tools
run: python -m pip install cmake-format
- name: Format CMake
run: cmake-format -i $(eval "${FIND_CMAKE_FILES_CMD}")
- name: Check if patching is required
id: patch-required
run: |
git -C '${{ github.workspace }}' diff --patch-with-raw > "${FORMAT_PATCH}"
test -s "${FORMAT_PATCH}" && {
printf "${RED}The source code does not meet the format requirements. \
Please, apply the patch (see artifacts).${DEFAULT}\n"
printf "${RED}Note that the result of the formatting might depend \
on the versions of the formatting tools. In this project, whatever \
formatting this CI job produces if the correct one. If it expects \
you to reformat parts of the source code that you did not modify, do \
so in a separate commit, which must not be squashed, and list the \
commit in the '.git-blame-ignore-revs' file.${DEFAULT}\n"
exit 1
} || {
printf "${GREEN}The source code meets the format requirements.${DEFAULT}\n"
rm -rf "${FORMAT_PATCH}"
}
- name: Upload the patch file
if: always() && steps.patch-required.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: format-patch
path: ${{ env.FORMAT_PATCH }}
Lint:
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '>=3.8'
- name: Install required tools
run: python -m pip install cmake-format
- name: Lint CMake
run: cmake-lint $(eval "${FIND_CMAKE_FILES_CMD}")
python-version: 3.x
- name: Run pre-commit
uses: pre-commit/[email protected]
6 changes: 5 additions & 1 deletion .gitlab/levante.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ include:
- local: '.gitlab/common.yml'

variables:
TIME_LIMIT: "05:00"
SCHEDULER_PARAMETERS: >-
--account=mh0287
--time=05:00
--time=${TIME_LIMIT}
${EXTRA_SCHEDULER_PARAMETERS}
EXTRA_SCHEDULER_PARAMETERS:

Expand Down Expand Up @@ -67,6 +68,9 @@ variables:
- .nag
- .common-levante
variables:
# Test executables produced in this configuration are too slow to run within
# the default time limit:
TIME_LIMIT: "10:00"
# Compiler flags used for ICON model:
FFLAGS: -Wc=/sw/spack-levante/gcc-11.2.0-bcn7mb/bin/gcc -f2008 -colour -w=uep -g -gline -O0 -float-store -nan -Wc,-g -Wc,-pipe -Wc,--param,max-vartrack-size=200000000 -Wc,-mno-fma -C=all

Expand Down
3 changes: 2 additions & 1 deletion .gitlab/lumi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ include:
aud: https://gitlab.com

variables:
TIME_LIMIT: "05:00"
SCHEDULER_PARAMETERS: >-
--account=project_465000454
--nodes=1
--ntasks=1
--cpus-per-task=4
--mem-per-cpu=1G
--time=05:00
--time=${TIME_LIMIT}
${EXTRA_SCHEDULER_PARAMETERS}
EXTRA_SCHEDULER_PARAMETERS:

Expand Down
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ci:
autofix_prs: false
autoupdate_branch: develop

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/rhysd/actionlint
rev: v1.7.6
hooks:
- id: actionlint
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-format
name: cmake-format (templates)
types: [file]
files: \.cmake\.in$
- id: cmake-lint
- id: cmake-lint
name: cmake-lint (templates)
types: [file]
files: \.cmake\.in$
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/csachs/pyproject-flake8
rev: v7.0.0
hooks:
- id: pyproject-flake8
12 changes: 6 additions & 6 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors:
given-names: Robert
orcid: "https://orcid.org/0000-0002-0016-3470"
- family-names: Iacono
given-names: Michael J.
given-names: Michael J.
orcid: "https://orcid.org/0000-0002-9578-0649"
- family-names: Alexeev
given-names: Dmitry
given-names: Dmitry
orcid: "https://orcid.org/0000-0002-6425-2181"
- family-names: Adamidis
given-names: Panos
Expand All @@ -19,12 +19,12 @@ authors:
given-names: Matthew
orcid: "https://orcid.org/0000-0003-4764-3348"
- family-names: Pfister
given-names: Erik
given-names: Erik
orcid: "http://orcid.org/0009-0002-2688-138X"
- family-names: Polonsky
given-names: Igor N.
- family-names: Romero
given-names: Nicols A.
given-names: Nicols A.
- family-names: Kosukhin
given-names: Sergey S.
- family-names: Wehe
Expand All @@ -35,7 +35,7 @@ license: BSD-3-Clause
date-released: "2023-11-27"
version: 1.7

abstract: "RTE+RRTMGP is a set of codes for computing radiative fluxes in planetary atmospheres.
abstract: "RTE+RRTMGP is a set of codes for computing radiative fluxes in planetary atmospheres.
RRTMGP uses a k-distribution to provide an optical description (absorption and possibly Rayleigh optical depth) of the gaseous atmosphere, along with the relevant source functions, on a pre-determined spectral grid given temperatures, pressures, and gas concentration. RTE computes fluxes given spectrally-resolved optical descriptions and source functions. The fluxes are normally summarized or reduced via a user extensible class."
identifiers:
- description: "All versions"
Expand Down Expand Up @@ -65,4 +65,4 @@ references:
volume: 11
number: 10
pages: 3074-3089
year: 2019
year: 2019
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(
LANGUAGES Fortran
)

option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_TESTING "Build tests" OFF)

option(RTE_ENABLE_SP "Enable single-precision floating-point model" OFF)
Expand All @@ -19,17 +20,24 @@ set_property(CACHE KERNEL_MODE PROPERTY STRINGS ${PREFERRED_KERNEL_MODES})

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# CMake does not support the NEC compiler and usually mistakes it for GNU:
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
# Check whether the Fortran compiler in use is NEC:
include(CheckCompilerIsNEC)
check_compiler_is_nec(RTE_RRTMGP_Fortran_is_NEC Fortran)
endif()

# GNUInstallDirs issues a warning if CMAKE_SIZEOF_VOID_P is not defined, which
# is the case with NAG. One way to circumvent that is to enable C language for
# the project:
if(CMAKE_Fortran_COMPILER_ID STREQUAL NAG)
# is the case with NAG and NEC. One way to circumvent that is to enable C
# language for the project:
if(CMAKE_Fortran_COMPILER_ID STREQUAL NAG OR RTE_RRTMGP_Fortran_is_NEC)
enable_language(C)
endif()
include(GNUInstallDirs)

add_compile_options(
$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-ffree-line-length-none>
)
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND NOT RTE_RRTMGP_Fortran_is_NEC)
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-ffree-line-length-none>)
endif()

set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)

Expand Down
12 changes: 6 additions & 6 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Thanks for considering making a contribution to RTE+RRTMGP.

The code in this repository is intended to work with compilers supporting the Fortran 2008 standard. It is also expected to run end-to-end on GPUs when compiled with OpenACC or OpenMP (though OpenMP is still unreliable). Commits are tested automatically against a range of compilers using Github Actions and also resources provided by the [Swiss Supercomputing Center](https://cscs.ch). The testing uses two general codes in `examples/`for which results are compared against existing implemetations, and custom codes in `tests/` intended to excercise all code options.

##### Did you find a bug?
##### Did you find a bug?

Please file an issue on the [Github page](https://github.com/RobertPincus/rte-rrtmgp/issues). Please include a minimal reproducer of the bug it at all possible.
Please file an issue on the [Github page](https://github.com/RobertPincus/rte-rrtmgp/issues). Please include a minimal reproducer of the bug it at all possible.

##### Did you write a patch that fixes a bug?

Please fork this repository, branch from `develop`, make your changes, and open a Github [pull request](https://github.com/RobertPincus/rte-rrtmgp/pulls) against branch `develop`.
Please fork this repository, branch from `develop`, make your changes, and open a Github [pull request](https://github.com/RobertPincus/rte-rrtmgp/pulls) against branch `develop`.

##### Did you add functionality?
##### Did you add functionality?

Please fork this repository, branch from `develop`, make your changes, and open a Github [pull request](https://github.com/RobertPincus/rte-rrtmgp/pulls) against branch `develop`, adding a new regression test or comparison against the reference in `tests/verification.py` or `tests/validation-plots.py` as appropriate. Add the test to the `tests` target in `tests/Makefile`.
Please fork this repository, branch from `develop`, make your changes, and open a Github [pull request](https://github.com/RobertPincus/rte-rrtmgp/pulls) against branch `develop`, adding a new regression test or comparison against the reference in `tests/verification.py` or `tests/validation-plots.py` as appropriate. Add the test to the `tests` target in `tests/Makefile`.

RTE+RRTMGP is intended to be a core that users can extend with custom code to suit their own needs.
RTE+RRTMGP is intended to be a core that users can extend with custom code to suit their own needs.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[RTE+RRTMGP's GitHub Pages site](https://earth-system-radiation.github.io/rte-rrtmgp/) contains
a mix of automatically-generated documentation and hand-written descriptions. The documentation is
incomplete and evolving. Thanks to the folks at [Sourcery Institute](https://www.sourceryinstitute.org)
for help in setting this up.
for help in setting this up.

For the moment the [Wiki](https://github.com/earth-system-radiation/rte-rrtmgp/wiki) may also be useful.

Expand All @@ -20,22 +20,22 @@ RTE computes fluxes given spectrally-resolved optical descriptions and source fu

A description of building RTE+RRTMGP with an ad hoc homemade system is described in the [documentation](https://earth-system-radiation.github.io/rte-rrtmgp/how-tos/).

See also the `autoconf` branch for a Gnu autotools build system.
See also the `autoconf` branch for a Gnu autotools build system.

## Examples

Two examples are provided in `examples/`, one for clear skies and one including clouds. Directory `tests/` contains regression testing (e.g. to ensure that answers are independent of orientation) and unit testing (to be sure all the code paths are tested). See the README file and codes in each directory for further information.

## Citing the code
## Citing the code

Code releases are archived at Zenodo. All releases are available at
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3403172.svg)](https://doi.org/10.5281/zenodo.3403172).
Code releases are archived at Zenodo. All releases are available at
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3403172.svg)](https://doi.org/10.5281/zenodo.3403172).
The current release is available at: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7521518.svg)](https://doi.org/10.5281/zenodo.10211873)

Please cite the code using these DOIs and the information in the `CITATION.cff` file in addition to the reference [paper](https://doi.org/10.1029/2019MS001621)

## Acknowledgements

The development of RTE+RRTMGP has been funded in the US by the Office of Naval Research, NASA, NOAA, and the Department of Energy. We
are grateful for contributions from a range of collaborators at institutions including the Swiss Supercomputing Center,
the German Climate Computing Center, and Nvidia.
The development of RTE+RRTMGP has been funded in the US by the Office of Naval Research, NASA, NOAA, and the Department of Energy. We
are grateful for contributions from a range of collaborators at institutions including the Swiss Supercomputing Center,
the German Climate Computing Center, and Nvidia.
Loading

0 comments on commit fbf5f5e

Please sign in to comment.