Skip to content

Commit e68ad73

Browse files
RobertPincusclementvalbrhillmanalexeedminpolonsky
authored
Accumulated changes from develop
Moving accumulated changes from branch develop onto master. *) Bug fixes: rescaling LW calculation to treat scattering *) Sensitivity (Jacobian) of LW fluxes to surface temperature *) NRLSSI2 model of solar variability including the ability to specify total solar irradiance (earth-system-radiation#43) *) Parameterization for optimal single angle at which to do LW no-scattering calculations Argument lists for ty_gas_optics_rrtmgp%load() are changed for both LW and SW versions. The optimal angle works but has no effect; updated data to come. Testing and continuous integration has also been expanded, including a new set of regression tests in tests/ Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com> Co-authored-by: Benjamin R. Hillman <bhillma@sandia.gov> Co-authored-by: Dmitry Alexeev <53860485+alexeedm@users.noreply.github.com> Co-authored-by: inpolonsky <51209434+inpolonsky@users.noreply.github.com> Co-authored-by: jdelamere <jdelamere@users.noreply.github.com>
1 parent 69d36c9 commit e68ad73

33 files changed

+2139
-263
lines changed

.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
Makefile.libs
1515
Makefile.conf
1616

17-
src/
17+
# Intel code coverage
18+
*.dyn
19+
*.dpi
20+
*.spi
21+
*.spl
22+
*.HTML
23+
*.html
24+
*.gif

.travis.yml

+63-25
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ language: cpp
77
# - RTE_KERNELS="openacc"
88
matrix:
99
include:
10-
- compiler: gcc # Using
10+
- name: "PGI community edition "
11+
compiler: gcc
1112
env:
1213
- FC=pgfortran
1314
- FCFLAGS="-Mallocatable=03 -Mstandard -Mbounds -Mchkptr -Kieee -Mchkstk"
@@ -20,10 +21,11 @@ matrix:
2021
- gcc-8
2122
- gfortran-8
2223
- libnetcdf-dev
23-
- compiler: gcc
24+
- name: "gcc-9"
25+
compiler: gcc
2426
env:
2527
- FC=gfortran-9
26-
- FCFLAGS="-ffree-line-length-none -m64 -std=f2003 -march=native -fbounds-check -finit-real=nan -DUSE_CBOOL"
28+
- FCFLAGS="-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -finit-real=nan -DUSE_CBOOL"
2729
- TEST_PGI=no
2830
- NCHOME=/usr/
2931
addons:
@@ -34,10 +36,11 @@ matrix:
3436
- gcc-9
3537
- gfortran-9
3638
- libnetcdf-dev
37-
- compiler: gcc
39+
- name: "gcc-8"
40+
compiler: gcc
3841
env:
3942
- FC=gfortran-8
40-
- FCFLAGS="-ffree-line-length-none -m64 -std=f2003 -march=native -fbounds-check -finit-real=nan -DUSE_CBOOL"
43+
- FCFLAGS="-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -finit-real=nan -DUSE_CBOOL"
4144
- TEST_PGI=no
4245
- NCHOME=/usr/
4346
addons:
@@ -64,6 +67,7 @@ before_install:
6467
fi
6568

6669
# Install netcdf-fortran for PGI
70+
# git clone https://github.com/Unidata/netcdf-fortran.git
6771
- git clone https://github.com/Unidata/netcdf-fortran.git --branch v4.4.4
6872
- cd netcdf-fortran
6973
- FC=$FC ./configure --prefix=${HOME}/netcdff
@@ -82,57 +86,91 @@ install:
8286
# conda create --yes -n test python=$TRAVIS_PYTHON_VERSION
8387
- conda create --yes -n test python=3.7
8488
- source activate test
85-
- conda install --yes urllib3 netcdf4 xarray dask
89+
- conda install --yes urllib3 netcdf4 xarray dask scipy
8690

8791
before_script:
8892
- export RRTMGP_ROOT=$PWD
89-
- export RRTMGP_DIR=$PWD/build
93+
- export RRTMGP_BUILD=$PWD/build
9094
- export NFHOME=${HOME}/netcdff
9195
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NFHOME/lib
9296
- cd examples/rfmip-clear-sky
9397
- python3 ./stage_files.py
9498
- cd ../..
9599
script:
96-
# Build library - default kernels
97-
- cd build || exit 1
98-
- make || exit 1
99-
- cd .. || exit 1
100+
#
101+
# Default kernels
102+
#
103+
- cd ${RRTMGP_ROOT}
104+
#
105+
# Build library
106+
#
107+
- make -C build clean || exit 1
108+
- make -C build || exit 1
109+
#
100110
# Build and run RFMIP examples
101-
- cd examples/rfmip-clear-sky || exit 1
111+
#
112+
- cd ${RRTMGP_ROOT}/examples/rfmip-clear-sky || exit 1
102113
- make clean
103114
- make || exit 1
104115
- python3 ./run-rfmip-examples.py
105-
- python3 ./compare-to-reference.py --fail=1.e-4
106-
- cd ../..
116+
- python3 ./compare-to-reference.py --fail=7.e-4
117+
- make clean
118+
#
107119
# Build and run all-sky example
108-
- cd examples/all-sky || exit 1
120+
#
121+
- cd ${RRTMGP_ROOT}/examples/all-sky || exit 1
109122
- make clean
110123
- make || exit 1
111124
- python3 ./run-allsky-example.py
112125
- python3 ./compare-to-reference.py
113-
- cd ../..
126+
- make clean
114127
#
115-
# Build library - Open-acc kernels
128+
# Build and regression tests
116129
#
117-
- export RTE_KERNELS="openacc"
118-
- cd build || exit 1
130+
- cd ${RRTMGP_ROOT}/tests|| exit 1
119131
- make clean
120132
- make || exit 1
121-
- cd .. || exit 1
133+
- cp ${RRTMGP_ROOT}/examples/rfmip-clear-sky/multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-1-2_none.nc test_atmospheres.nc
134+
- ./clear_sky_regression test_atmospheres.nc ${RRTMGP_ROOT}/rrtmgp/data/rrtmgp-data-lw-g256-2018-12-04.nc
135+
- ./clear_sky_regression test_atmospheres.nc ${RRTMGP_ROOT}/rrtmgp/data/rrtmgp-data-sw-g224-2018-12-04.nc
136+
- python3 verification.py
137+
#
138+
# Open-acc kernels
139+
#
140+
- cd ${RRTMGP_ROOT}
141+
#
142+
# Build library
143+
#
144+
- make -C build clean || exit 1
145+
- make -C build || exit 1
146+
#
122147
# Build and run RFMIP examples
123-
- cd examples/rfmip-clear-sky || exit 1
148+
#
149+
- cd ${RRTMGP_ROOT}/examples/rfmip-clear-sky || exit 1
124150
- make clean
125151
- make || exit 1
126152
- python3 ./run-rfmip-examples.py
127-
- python3 ./compare-to-reference.py --fail=1.e-4
128-
- cd ../..
153+
- python3 ./compare-to-reference.py --fail=7.e-4
154+
- make clean
155+
#
129156
# Build and run all-sky example
130-
- cd examples/all-sky || exit 1
157+
#
158+
- cd ${RRTMGP_ROOT}/examples/all-sky || exit 1
131159
- make clean
132160
- make || exit 1
133161
- python3 ./run-allsky-example.py
134162
- python3 ./compare-to-reference.py
135-
- cd ../..
163+
- make clean
164+
#
165+
# Build and regression tests
166+
#
167+
- cd ${RRTMGP_ROOT}/tests|| exit 1
168+
- make clean
169+
- make || exit 1
170+
- cp ${RRTMGP_ROOT}/examples/rfmip-clear-sky/multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-1-2_none.nc test_atmospheres.nc
171+
- ./clear_sky_regression test_atmospheres.nc ${RRTMGP_ROOT}/rrtmgp/data/rrtmgp-data-lw-g256-2018-12-04.nc
172+
- ./clear_sky_regression test_atmospheres.nc ${RRTMGP_ROOT}/rrtmgp/data/rrtmgp-data-sw-g224-2018-12-04.nc
173+
- python3 verification.py
136174
notifications:
137175
email:
138176
on_success: never

Contributing.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Contributing to RTE+RRTMGP
2+
3+
Thanks for considering making a contribution to RTE+RRTMGP.
4+
5+
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. Commits are tested with [Travis](https://travis-ci.com) against gfortran versions 8 and 9 and against various versions > 19.9 of the PGI compiler using 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.
6+
7+
##### Did you find a bug?
8+
9+
Please file an issue on the [Github page](https://github.com/RobertPincus/rte-rrtmgp/issues).
10+
11+
##### Did you write a patch that fixes a bug?
12+
13+
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`.
14+
15+
##### Did you add functionality?
16+
17+
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.
18+
19+
RTE+RRTMGP is intended to be a core that users can extend with custom code to suit their own needs.

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ RRTMGP uses a k-distribution to provide an optical description (absorption and p
66

77
RTE computes fluxes given spectrally-resolved optical descriptions and source functions. The fluxes are normally summarized or reduced via a user extensible class.
88

9-
Example programs and documenation are evolving - please see examples/ in the repo and Wiki on the project's Github page. Suggestions are welcome. Meanwhile for questions please contact Robert Pincus and Eli Mlawer at rrtmgp@aer.com.
9+
Example programs and documentation are evolving - please see examples/ in the repo and Wiki on the project's Github page. Suggestions are welcome. Meanwhile for questions please contact Robert Pincus and Eli Mlawer at rrtmgp@aer.com.
10+
11+
## Recent changes
12+
13+
1. The default method for solution for longwave problems that include scattering has been changed from 2-stream methods to a re-scaled and refined no-scattering calculation following [Tang et al. 2018](https://doi.org/10.1175/JAS-D-18-0014.1).
14+
2. In RRTMGP gas optics, the spectrally-resolved solar source function in can be adjusted by specifying the total solar irradiance (`gas_optics%set_tsi(tsi)`) and/or the facular and sunspot indicies (`gas_optics%set_solar_variability(mg_index, sb_index, tsi)`)from the [NRLSSI2 model of solar variability](http://doi.org/10.1175/BAMS-D-14-00265.1).
15+
3. `rte_lw()` now includes optional arguments for computing the Jacobian (derivative) of broadband flux with respect to changes in surface temperature. In calculations neglecting scattering only the Jacobian of upwelling flux is computed. When using re-scaling to account for scattering the Jacobians of both up- and downwelling flux are computed.
16+
17+
Relative to commit `69d36c9` to `master` on Apr 20, 2020, the required arguments to both the longwave and shortwave versions of `ty_gas_optics_rrtmgp%load()`have changed.
1018

11-
In the most recent revision, the default method for solution for longwave problems that include scattering has been changed from 2-stream methods to a re-scaled and refined no-scattering calculation following [Tang et al. 2018](https://doi.org/10.1175/JAS-D-18-0014.1).
1219

1320
## Building the libraries.
1421

azure-pipelines.yml

+40-16
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,35 @@ jobs:
44
strategy:
55
matrix:
66
pgi_19_9_gpu:
7-
compiler_module: PGI/19.9.0
7+
compiler_module: PGI/19.9
8+
PrgEnv: PrgEnv-pgi
89
accel_module: cudatoolkit
9-
FCFLAGS: "-O3 -ta=tesla:cc60,cuda10.1 -Minfo -Mallocatable=03 -gopt -Minline,reshape,maxsize:40"
10+
FCFLAGS: "-O3 -ta=tesla:cc60,cuda10.1 -Mallocatable=03 -gopt -Minline,reshape,maxsize:40"
1011
RTE_KERNELS: openacc
1112
pgi_default_gpu:
1213
compiler_module: pgi
14+
PrgEnv: PrgEnv-pgi
1315
accel_module: craype-accel-nvidia60
1416
# Generic accelerator flag
15-
FCFLAGS: "-O3 -acc -Minfo -Mallocatable=03 -gopt"
17+
FCFLAGS: "-O3 -acc -Mallocatable=03 -gopt"
1618
RTE_KERNELS: openacc
19+
pgi_19_10_cpu:
20+
compiler_module: PGI/19.10
21+
PrgEnv: PrgEnv-pgi
22+
accel_module:
23+
# Error checking flags
24+
FCFLAGS: "-Mallocatable=03 -Mstandard -Mbounds -Mchkptr -Kieee -Mchkstk"
25+
RUN_CMD:
1726
pgi_19_9_cpu:
18-
compiler_module: PGI/19.9.0
27+
compiler_module: PGI/19.9
28+
PrgEnv: PrgEnv-pgi
1929
accel_module:
2030
# Error checking flags
2131
FCFLAGS: "-Mallocatable=03 -Mstandard -Mbounds -Mchkptr -Kieee -Mchkstk"
32+
RUN_CMD:
2233
pgi_default_cpu:
2334
compiler_module: pgi
35+
PrgEnv: PrgEnv-pgi
2436
accel_module:
2537
# Error checking flags
2638
FCFLAGS: "-Mallocatable=03 -Mstandard -Mbounds -Mchkptr -Kieee -Mchkstk"
@@ -32,21 +44,21 @@ jobs:
3244
steps:
3345
- script: |
3446
set -e
35-
47+
3648
echo "
3749
export PATH=$CRAY_BINUTILS_BIN:$PATH
3850
module load daint-gpu
39-
module swap PrgEnv-cray PrgEnv-pgi
51+
module swap PrgEnv-cray $(PrgEnv)
4052
module load cray-netcdf cray-hdf5
4153
module swap pgi $(compiler_module)
4254
module load $(accel_module)
4355
module load cray-python/3.6.5.7
4456
export LD_LIBRARY_PATH=$CRAY_LD_LIBRARY_PATH:$LD_LIBRARY_PATH
45-
57+
4658
echo Environment:
4759
module list
4860
" > modules
49-
61+
5062
displayName: 'Create module environment'
5163
- script: |
5264
set -e
@@ -60,29 +72,41 @@ jobs:
6072
set -e
6173
source modules
6274
export RRTMGP_ROOT=$PWD
63-
export RRTMGP_DIR=$PWD/build
75+
export RRTMGP_BUILD=$PWD/build
6476
export FC=ftn
77+
make -C build/ clean
78+
6579
make -C build/ -j 8
80+
make -C tests clean
81+
make -C tests -j 1
82+
make -C examples/all-sky clean
6683
make -C examples/all-sky -j 8
84+
make -C examples/rfmip-clear-sky clean
6785
make -C examples/rfmip-clear-sky -j 8
6886
displayName: 'Make'
6987
- script: |
7088
set -e
7189
source modules
72-
cd examples/rfmip-clear-sky
90+
export RRTMGP_ROOT=$PWD
91+
cd ${RRTMGP_ROOT}/examples/rfmip-clear-sky
7392
srun -C gpu -A c15 -p cscsci python ./run-rfmip-examples.py --block_size 1800
74-
cd ../..
75-
cd examples/all-sky
93+
cd ${RRTMGP_ROOT}/examples/all-sky
7694
srun -C gpu -A c15 -p cscsci python ./run-allsky-example.py
95+
cd ${RRTMGP_ROOT}/tests
96+
cp ${RRTMGP_ROOT}/examples/rfmip-clear-sky/multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-1-2_none.nc test_atmospheres.nc
97+
srun -C gpu -A c15 -p cscsci ./clear_sky_regression test_atmospheres.nc ${RRTMGP_ROOT}/rrtmgp/data/rrtmgp-data-lw-g256-2018-12-04.nc
98+
srun -C gpu -A c15 -p cscsci ./clear_sky_regression test_atmospheres.nc ${RRTMGP_ROOT}/rrtmgp/data/rrtmgp-data-sw-g224-2018-12-04.nc
7799
displayName: 'Run'
78100
- script: |
79101
set -e
80102
source modules
103+
export RRTMGP_ROOT=$PWD
81104
# This module will unload some of the build modules, so do the checks separately
82105
module load netcdf-python
83-
cd examples/rfmip-clear-sky
84-
python ./compare-to-reference.py --fail=1.e-4
85-
cd ../..
86-
cd examples/all-sky
106+
cd ${RRTMGP_ROOT}/examples/rfmip-clear-sky
107+
python ./compare-to-reference.py --fail=7.e-4
108+
cd ${RRTMGP_ROOT}/examples/all-sky
87109
python ./compare-to-reference.py
110+
cd ${RRTMGP_ROOT}/tests
111+
python verification.py
88112
displayName: 'Check results'

build/Makefile.conf.ifort

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export FC = ifort
88
#
99
# Optimized
1010
#
11-
export FCFLAGS += -m64 -O3 -g -traceback -assume realloc_lhs -extend-source 132
11+
export FCFLAGS += -m64 -O3 -g -traceback -heap-arrays -assume realloc_lhs -extend-source 132
1212
export F77FLAGS += -m64 -O3 -g -traceback
1313
# can add -qopt-report-phase=vec
1414
#
1515
# Debugging
1616
#
17-
# export FCFLAGS = -m64 -g -traceback -assume realloc_lhs -extend-source 132 -check bounds,uninit,pointers,stack -stand f03
17+
# export FCFLAGS = -m64 -g -traceback -heap-arrays -assume realloc_lhs -extend-source 132 -check bounds,uninit,pointers,stack -stand f08
1818
# export F77FLAGS = -m64 -g -traceback -check bounds,uninit,pointers,stack

examples/all-sky/compare-to-reference.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# If a version of the file exists in the reference directory, no need to download (can be over-ridden)
3232
if (args.download_reference or not os.path.exists(ref_file)):
3333
os.makedirs(args.ref_dir, exist_ok=True)
34-
urllib.request.urlretrieve("https://owncloud.gwdg.de/index.php/s/wgCL7imbA0QRCEf/download", ref_file)
34+
urllib.request.urlretrieve("https://owncloud.gwdg.de/index.php/s/OjbNzRTlXUk0G5w/download", ref_file)
3535
tst = xr.open_dataset(tst_file)
3636
ref = xr.open_dataset(ref_file)
3737

@@ -42,8 +42,10 @@
4242
if np.any(np.isnan(tst.variables[v].values)):
4343
raise Exception("Some test values are missing. Now that is strange.")
4444

45-
diff = abs((tst-ref).variables[v].values)
46-
avg = 0.5*(tst+ref).variables[v].values
45+
# express as (tst-ref).variables[v].values when replacing reference file
46+
# to have same number of columns
47+
diff = abs((tst.variables[v]-ref.variables[v]).values)
48+
avg = 0.5*(tst.variables[v]+ref.variables[v]).values
4749
# Division raises a runtime warning when we divide by zero even if the
4850
# values in those locations will be ignored.
4951
with np.errstate(divide='ignore', invalid='ignore'):

examples/all-sky/garand-atmos-1.nc

107 KB
Binary file not shown.

examples/all-sky/rrtmgp-allsky.nc

-1.41 MB
Binary file not shown.

examples/all-sky/run-allsky-example.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
#
33
# This script runs runs the RTE+RRTMGP all-sky examples
44
#
5-
import os, subprocess, glob
5+
import os
6+
import shutil
7+
import subprocess
8+
import glob
69
import argparse
710

811
rte_rrtmgp_dir = os.path.join("..", "..")
9-
# This files lives in $RRTMGP_DIR/examples/all-sky/
12+
# This files lives in $RRTMGP_ROOT/examples/all-sky/
1013
all_sky_dir = "."
1114
# Code should be run in the all_sky_dir directory
1215

@@ -18,8 +21,10 @@
1821

1922
# In the local directory
2023
all_sky_exe_name = os.path.join(all_sky_dir, "rrtmgp_allsky")
24+
input_file = os.path.join(all_sky_dir, "garand-atmos-1.nc")
2125
atmos_file = os.path.join(all_sky_dir, "rrtmgp-allsky.nc")
2226

27+
2328
if __name__ == '__main__':
2429
parser = argparse.ArgumentParser(description="Runs all-sky examples, resetting output.")
2530
parser.add_argument("--run_command", type=str, default="",
@@ -38,7 +43,7 @@
3843

3944
os.chdir(all_sky_dir)
4045
# Remove cloudy-sky fluxes from the file containing the atmospheric profiles
41-
subprocess.run(["git", "checkout", atmos_file])
46+
shutil.copyfile(input_file, atmos_file)
4247
subprocess.run([all_sky_exe_name, atmos_file, lw_gas_coeffs_file, lw_clouds_coeff_file, ncol_str, nloops_str])
4348
subprocess.run([all_sky_exe_name, atmos_file, sw_gas_coeffs_file, sw_clouds_coeff_file, ncol_str, nloops_str])
4449

0 commit comments

Comments
 (0)