Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kernel API #272

Merged
merged 35 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e07653e
C header files
RobertPincus Mar 6, 2024
c8ee729
Adding Fortran interface files for kernels
RobertPincus Mar 7, 2024
fd719b6
Define floating point and Boolean types
RobertPincus Mar 7, 2024
af4c7fd
D'oh! C order.
RobertPincus Mar 7, 2024
59603b1
Fix syntax errors in rte_kernels.h
makepath-alex Mar 9, 2024
49d22d7
More information in C header describing solvers
RobertPincus Mar 12, 2024
c11ed31
Doc for arguments for all solvers in C headers
RobertPincus Mar 12, 2024
3523321
Incrementing function arguments documented in C headers
RobertPincus Mar 12, 2024
ac667aa
Complete documentation of RTE kernels in C header
RobertPincus Mar 13, 2024
7913e95
More uniform Makefiles
RobertPincus Mar 13, 2024
713735e
YML typo
RobertPincus Mar 13, 2024
b5bfeb8
Makefile addition
RobertPincus Mar 13, 2024
2545858
Add new workflow to CI to check Fortran API
RobertPincus Mar 13, 2024
edef205
Add new workflow to CI to check Fortran API (for real)
RobertPincus Mar 13, 2024
15f092a
Fix compile error in rte-kernels/api/rte_kernels.h
makepath-alex Mar 18, 2024
cbd3ddc
Two kernels in the C header annotated
RobertPincus Mar 19, 2024
5f4809c
Revised RRTMGP C headers
RobertPincus Mar 20, 2024
c86d51a
Uniform format for C headers, revert to C++ type definitions
RobertPincus Mar 21, 2024
651b04f
Fix issues with C headers in rrtmgp
makepath-alex Mar 22, 2024
4e5ebb9
Restores all rte_kernels.h. Will switch to new one later
makepath-alex Mar 22, 2024
91b9412
Fix wrong definition for rte_inc_1scalar_by_nstream_bybnd
makepath-alex Mar 22, 2024
3b4b7a9
Fix a typo causing compilation issues
makepath-alex Mar 22, 2024
77f327c
Update C bindings for sum_byband and net_byband_full
makepath-alex Mar 22, 2024
84256d1
Properly switch rte kernels to using C++ style declarations
makepath-alex Mar 22, 2024
b402205
Missing & character
RobertPincus Mar 23, 2024
81a645a
C header change of style: type & -> type&
RobertPincus Mar 23, 2024
5c0559a
Merge branch 'develop' into feature-add-kernel-api
RobertPincus Mar 23, 2024
8102142
Relax OLR threhsold for rad. equil with GPUs.
RobertPincus Mar 26, 2024
5837766
Revert change
RobertPincus Mar 26, 2024
31c002e
vpath syntax
RobertPincus Mar 27, 2024
fb575a9
Further vpath syntax
RobertPincus Mar 27, 2024
9a2eef8
API build change?
RobertPincus Mar 28, 2024
a8f18bd
Explicit public interface?
RobertPincus Mar 28, 2024
8a955cb
Fix in rte_inc_1scalar_by_nstream_bybnd declaration
makepath-alex Mar 29, 2024
cc8d587
Example executable depended on libraries so tried to link them twice.
RobertPincus Apr 2, 2024
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
34 changes: 34 additions & 0 deletions .github/workflows/check-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check Fortran API
on:
push:
branches:
- main
- develop
pull_request:
branches-ignore:
- documentation
workflow_dispatch:


jobs:
API:
runs-on: ubuntu-22.04
env:
# Core variables:
FC: gfortran-12
FCFLAGS: "-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -fmodule-private -fimplicit-none -finit-real=nan -g -DRTE_USE_CBOOL"
RRTMGP_ROOT: ${{ github.workspace }}
RTE_KERNELS: extern
steps:
#
# Check out repository under $GITHUB_WORKSPACE
#
- name: Check out code
uses: actions/checkout@v4
#
# Build libraries
#
- name: Build libraries
run: |
$FC --version
make -j4 libs
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ jobs:
#
# Build libraries, examples and tests
#
- name: Build libraries, examples and tests
- name: Build libraries
run: |
$FC --version
make -j4 libs
#
# Run examples and tests
#
- name: Run examples and tests
- name: Build and run examples and tests
run: make -j4 tests
#
# Compare the results
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/self-hosted-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
env:
# Core variables:
FC: ftn
FCFLAGS: ${{ matrix.fcflags }} -DRTE_USE_${{ matrix.fpmodel}}
FCFLAGS: ${{ matrix.fcflags }} -DRTE_USE_${{ matrix.fpmodel }}
# Make variables:
RRTMGP_ROOT: ${{ github.workspace }}
RRTMGP_DATA: ${{ github.workspace }}/rrtmgp-data
Expand Down Expand Up @@ -93,21 +93,21 @@ jobs:
#
# Build libraries, examples and tests
#
- name: Build libraries, examples and tests
- name: Build libraries
run: |
$FC --version
make -j8 libs
#
# Run examples and tests (expect success)
#
- name: Run examples and tests (expect success)
- name: Build and run examples and tests (expect success)
id: run-success
if: matrix.config-name != 'cce-gpu-openmp'
run: make -j8 tests
#
# Run examples and tests (expect failure)
#
- name: Run examples and tests (expect failure)
- name: Build and run examples and tests (expect failure)
if: steps.run-success.outcome == 'skipped'
run: |
make -j8 tests && {
Expand Down
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
#
# Top-level Makefile
#
.PHONY: libs tests check docs
all: libs tests check docs
.PHONY: libs tests check
all: libs tests check

libs:
$(MAKE) -C build
$(MAKE) -C tests
$(MAKE) -C examples/all-sky
$(MAKE) -C examples/rfmip-clear-sky
$(MAKE) -C build $@

tests:
$(MAKE) -C tests $@
$(MAKE) -C examples/rfmip-clear-sky $@
$(MAKE) -C examples/all-sky $@
$(MAKE) -C tests $@

check:
$(MAKE) -C tests $@
$(MAKE) -C examples/rfmip-clear-sky $@
$(MAKE) -C examples/all-sky $@
$(MAKE) -C tests $@

docs:
@cd doc; ./build_documentation.sh

clean:
$(MAKE) -C build $@
$(MAKE) -C tests $@
$(MAKE) -C examples/rfmip-clear-sky $@
$(MAKE) -C examples/all-sky $@
$(MAKE) -C tests $@
rm -rf public
26 changes: 21 additions & 5 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RRTMGP_KERNEL_DIR = ../rrtmgp-kernels
all: librte.a librrtmgp.a \
librtekernels.a librtef.a librrtmgpkernels.a librrtmgpf.a
separate-libs: librtekernels.a librtef.a librrtmgpkernels.a librrtmgpf.a
libs: all

COMPILE = $(FC) $(FCFLAGS) $(FCINCLUDE) -c
%.o: %.F90
Expand All @@ -22,23 +23,38 @@ include $(RRTMGP_DIR)/Make.depends
include $(RTE_KERNEL_DIR)/Make.depends
include $(RRTMGP_KERNEL_DIR)/Make.depends

VPATH = $(RTE_DIR):$(RTE_KERNEL_DIR):$(RRTMGP_DIR):$(RRTMGP_KERNEL_DIR):$(GAS_OPTICS_DIR)
#
# If using OpenACC/OpenMP files in *-kernels/accel take precendence
#
ifeq ($(RTE_KERNELS), accel)
VPATH = $(RTE_DIR):$(RTE_KERNEL_DIR)/accel:$(RTE_KERNEL_DIR):$(RRTMGP_DIR):$(RRTMGP_KERNEL_DIR)/accel:$(RRTMGP_KERNEL_DIR):$(GAS_OPTICS_DIR)
VPATH = $(RTE_KERNEL_DIR)/accel:$(RRTMGP_KERNEL_DIR)/accel
endif
#
# If using external libraries just compile the interfaces
#
ifeq ($(RTE_KERNELS), extern)
VPATH = $(RTE_KERNEL_DIR)/api:$(RRTMGP_KERNEL_DIR)/api
endif
VPATH += $(RTE_DIR):$(RTE_KERNEL_DIR):$(RRTMGP_DIR):$(RRTMGP_KERNEL_DIR):$(GAS_OPTICS_DIR)

#
# Complete library - kernels plus Fortran front end
#
librte.a: $(RTE_FORTRAN_KERNELS) $(RTE_FORTRAN_INTERFACE)
ar -rvs librte.a $(RTE_FORTRAN_KERNELS) $(RTE_FORTRAN_INTERFACE)

#
# Library with just the kernels...
#
librtekernels.a: $(RTE_FORTRAN_KERNELS)
ar -rvs librtekernels.a $(RTE_FORTRAN_KERNELS)

#
# ... and just the Fortran front-end
#
librtef.a: $(RTE_FORTRAN_INTERFACE)
ar -rvs librtef.a $(RTE_FORTRAN_INTERFACE)

#
# As with RTE, libraries with Fortran front-end and kernels, separate and combined
#
librrtmgp.a: $(RRTMGP_FORTRAN_KERNELS) $(RRTMGP_FORTRAN_INTERFACE)
ar -rvs librrtmgp.a $(RRTMGP_FORTRAN_KERNELS) $(RRTMGP_FORTRAN_INTERFACE)

Expand Down
3 changes: 2 additions & 1 deletion examples/all-sky/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env make
#
# Location of RTE+RRTMGP libraries, module files.
#
Expand Down Expand Up @@ -46,7 +47,7 @@ mo_load_coefficients.o: mo_simple_netcdf.o
mo_load_cloud_coefficients.o: mo_simple_netcdf.o mo_cloud_optics_rrtmgp.o mo_load_cloud_coefficients.F90
mo_load_aerosol_coefficients.o: mo_simple_netcdf.o mo_aerosol_optics_rrtmgp_merra.o mo_load_aerosol_coefficients.F90

tests:
tests: rrtmgp_allsky
$(RUN_CMD) bash all_tests.sh

check:
Expand Down
13 changes: 7 additions & 6 deletions examples/rfmip-clear-sky/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env make
#
# Location of RTE+RRTMGP libraries, module files.
#
RRTMGP_BUILD = $(RRTMGP_ROOT)/build
#
# RRTMGP library, module files
#
# LDFLAGS += -L$(RRTMGP_BUILD)
# LIBS += -lrrtmgp -lrte
LDFLAGS += -L$(RRTMGP_BUILD)
LIBS += -lrrtmgp -lrte
FCINCLUDE += -I$(RRTMGP_BUILD)

#
# netcdf Fortran module files has to be in the search path or added via environment variable FCINCLUDE e.g.
#FCINCLUDE += -I$(NFHOME)/include

Expand Down Expand Up @@ -38,19 +38,20 @@ ADDITIONS = mo_simple_netcdf.o mo_rfmip_io.o mo_load_coefficients.o

all: rrtmgp_rfmip_lw rrtmgp_rfmip_sw

rrtmgp_rfmip_lw: rrtmgp_rfmip_lw.o $(ADDITIONS) $(RRTMGP_BUILD)/librrtmgp.a $(RRTMGP_BUILD)/librte.a
rrtmgp_rfmip_lw: rrtmgp_rfmip_lw.o $(ADDITIONS)

rrtmgp_rfmip_lw.o: rrtmgp_rfmip_lw.F90 $(ADDITIONS)

rrtmgp_rfmip_sw: rrtmgp_rfmip_sw.o $(ADDITIONS) $(RRTMGP_BUILD)/librrtmgp.a $(RRTMGP_BUILD)/librte.a
rrtmgp_rfmip_sw: rrtmgp_rfmip_sw.o $(ADDITIONS)

rrtmgp_rfmip_sw.o: rrtmgp_rfmip_sw.F90 $(ADDITIONS)

mo_rfmip_io.o: mo_rfmip_io.F90 mo_simple_netcdf.o

mo_load_coefficients.o: mo_load_coefficients.F90 mo_simple_netcdf.o

tests: multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-1-2_none.nc \
tests: rrtmgp_rfmip_lw rrtmgp_rfmip_sw \
multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-1-2_none.nc \
rld_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc rlu_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc \
rsd_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc rsu_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc
$(RUN_CMD) ./rrtmgp_rfmip_lw 8 multiple_input4MIPs_radiation_RFMIP_UColorado-RFMIP-1-2_none.nc ${RRTMGP_DATA}/rrtmgp-gas-lw-g256.nc
Expand Down
4 changes: 2 additions & 2 deletions extensions/mo_fluxes_byband.F90
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ end function are_desired_byband
!
! Spectral reduction over all points
!
subroutine sum_byband(ncol, nlev, ngpt, nbnd, band_lims, spectral_flux, byband_flux) bind (C)
subroutine sum_byband(ncol, nlev, ngpt, nbnd, band_lims, spectral_flux, byband_flux) bind(C, name="rte_sum_byband")
integer, intent(in ) :: ncol, nlev, ngpt, nbnd
integer, dimension(2, nbnd), intent(in ) :: band_lims
real(wp), dimension(ncol, nlev, ngpt), intent(in ) :: spectral_flux
Expand All @@ -181,7 +181,7 @@ end subroutine sum_byband
!
! Net flux: Spectral reduction over all points
!
subroutine net_byband_full(ncol, nlev, ngpt, nbnd, band_lims, spectral_flux_dn, spectral_flux_up, byband_flux_net) bind (C)
subroutine net_byband_full(ncol, nlev, ngpt, nbnd, band_lims, spectral_flux_dn, spectral_flux_up, byband_flux_net) bind(C, name="rte_net_byband_full")
integer, intent(in ) :: ncol, nlev, ngpt, nbnd
integer, dimension(2, nbnd), intent(in ) :: band_lims
real(wp), dimension(ncol, nlev, ngpt), intent(in ) :: spectral_flux_dn, spectral_flux_up
Expand Down
Loading
Loading