Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
boulderdaze committed Jan 10, 2024
2 parents 8d70c57 + 8e22784 commit 9897b8b
Show file tree
Hide file tree
Showing 32 changed files with 570 additions and 112 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ jobs:
run: docker build -t musica .
- name: run tests in container
run: docker run --name test-container -t musica bash -c 'make test'
build_test_connections_without_micm:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: build Docker image
run: docker build -t musica -f Dockerfile.no_micm .
- name: run tests in container
run: docker run --name test-container -t musica bash -c 'make test'
build_test_connections_with_openmp:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand Down Expand Up @@ -47,7 +58,21 @@ jobs:
run: docker build -t musica-mpi-openmp -f Dockerfile.mpi_openmp .
- name: run tests in container
run: docker run --name test-container -t musica-mpi-openmp bash -c 'make test'
build_test_connections_musica-fortran:
# build_test_connections_musica-fortran:
# runs-on: ubuntu-latest
# if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
# steps:
# - name: delete unnessary tools to free up space
# run: rm -rf /opt/hostedtoolcache

# - uses: actions/checkout@v2
# with:
# submodules: recursive
# - name: build Docker image
# run: docker build -t musica-fortran -f Dockerfile.fortran .
# - name: run tests in container
# run: docker run --name test-container -t musica-fortran bash -c 'make test'
build_test_connections_musica-fortran-same-compiler:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
Expand All @@ -58,6 +83,6 @@ jobs:
with:
submodules: recursive
- name: build Docker image
run: docker build -t musica-fortran -f Dockerfile.fortran .
run: docker build -t musica-fortran-ubuntu -f Dockerfile.fortran-ubuntu .
- name: run tests in container
run: docker run --name test-container -t musica-fortran bash -c 'make test'
run: docker run --name test-container -t musica-fortran-ubuntu bash -c 'make test'
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21)

project(
musica
VERSION 0.4.0
VERSION 0.5.0
LANGUAGES Fortran CXX C
)

Expand Down Expand Up @@ -54,6 +54,14 @@ include(GNUInstallDirs)
set(INSTALL_PREFIX "musica-${PROJECT_VERSION}")
set(INSTALL_MOD_DIR "${INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")

# MUSICA library components
if(ENABLE_TUVX)
add_definitions(-DMUSICA_USE_TUVX)
endif()
if(ENABLE_MICM)
add_definitions(-DMUSICA_USE_MICM)
endif()

# MPI
if(ENABLE_MPI)
add_definitions(-DMUSICA_USE_MPI)
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RUN dnf -y update \
lcov \
make \
netcdf-fortran-devel \
json-devel \
valgrind \
&& dnf clean all

Expand All @@ -35,5 +36,5 @@ RUN cd musica \
-D ENABLE_TESTS=ON \
&& cd build \
&& make install -j 8

WORKDIR musica/build
5 changes: 5 additions & 0 deletions Dockerfile.fortran
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RUN apt update \
libcurl4-openssl-dev \
libhdf5-dev \
m4 \
nlohmann-json3-dev \
vim \
zlib1g-dev \
git \
Expand Down Expand Up @@ -44,6 +45,7 @@ RUN cd musica \
&& cmake -S . \
-B build \
-D ENABLE_TESTS=ON \
-D ENABLE_TUVX=OFF \
&& cd build \
&& make install -j 8

Expand All @@ -67,4 +69,7 @@ RUN cd musica/musica-fortran/test \
&& cmake .. \
&& make

RUN cd musica/musica-fortran/test \
&& cp -r configs/chapman ./build/chapman

WORKDIR musica/musica-fortran/test/build
60 changes: 60 additions & 0 deletions Dockerfile.fortran-ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM ubuntu:22.04

RUN apt update \
&& apt -y install \
cmake \
cmake-curses-gui \
curl \
libcurl4-openssl-dev \
libhdf5-dev \
m4 \
nlohmann-json3-dev \
vim \
zlib1g-dev \
git \
lcov \
make \
libnetcdff-dev \
valgrind \
gcc \
gfortran \
g++ \
&& apt clean

# Set environment variables to install MUSICA using gcc
ENV FC=gfortran
ENV FFLAGS="-I/usr/include/"

# Install json-fortran for gnu version
RUN curl -LO https://github.com/jacobwilliams/json-fortran/archive/8.2.0.tar.gz \
&& tar -zxvf 8.2.0.tar.gz \
&& cd json-fortran-8.2.0 \
&& mkdir build \
&& cd build \
&& cmake -D SKIP_DOC_GEN:BOOL=TRUE .. \
&& make install

# Copy the musica code
COPY . musica

# Set json-fortran variable to install MUSICA using gcc
ENV JSON_FORTRAN_HOME="/usr/local/jsonfortran-gnu-8.2.0"

# Build and install MUSICA
RUN cd musica \
&& cmake -S . \
-B build \
-D ENABLE_TESTS=ON \
-D ENABLE_TUVX=OFF \
&& cd build \
&& make install -j 8

RUN cd musica/musica-fortran/test \
&& mkdir build && cd build \
&& cmake .. \
&& make

RUN cd musica/musica-fortran/test \
&& cp -r configs/chapman ./build/chapman

WORKDIR musica/musica-fortran/test/build
1 change: 1 addition & 0 deletions Dockerfile.mpi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN sudo dnf -y install \
make \
netcdf-fortran-devel \
openmpi-devel \
json-devel \
valgrind-openmpi \
&& dnf clean all

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.mpi_openmp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN sudo dnf -y install \
lcov \
make \
netcdf-fortran-devel \
json-devel \
openmpi-devel \
valgrind-openmpi \
&& dnf clean all
Expand Down
41 changes: 41 additions & 0 deletions Dockerfile.no_micm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM fedora:35

RUN dnf -y update \
&& dnf -y install \
cmake \
gcc-c++ \
gcc-gfortran \
git \
lcov \
make \
netcdf-fortran-devel \
valgrind \
&& dnf clean all

# Install json-fortran
RUN curl -LO https://github.com/jacobwilliams/json-fortran/archive/8.2.0.tar.gz \
&& tar -zxvf 8.2.0.tar.gz \
&& cd json-fortran-8.2.0 \
&& mkdir build \
&& cd build \
&& cmake -D SKIP_DOC_GEN:BOOL=TRUE .. \
&& make install

# Set environment variables
ENV FC=gfortran
ENV JSON_FORTRAN_HOME="/usr/local/jsonfortran-gnu-8.2.0"

# Copy the musica code
COPY . musica

# Build
RUN cd musica \
&& cmake -S . \
-B build \
-D ENABLE_TESTS=ON \
-D ENABLE_TUVX=ON \
-D ENABLE_MICM=OFF \
&& cd build \
&& make install -j 8

WORKDIR musica/build
1 change: 1 addition & 0 deletions Dockerfile.openmp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN sudo dnf -y install \
lcov \
make \
netcdf-fortran-devel \
json-devel \
openmpi-devel \
valgrind-openmpi \
&& dnf clean all
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# MUSICA
[![GitHub Releases](https://img.shields.io/github/release/NCAR/musica.svg)](https://github.com/NCAR/musica/releases)
[![License](https://img.shields.io/github/license/NCAR/musica.svg)](https://github.com/NCAR/musica/blob/main/LICENSE)
[![CI Status](https://github.com/NCAR/musica/actions/workflows/test.yml/badge.svg)](https://github.com/NCAR/musica/actions/workflows/test.yml)
<!-- [![DOI](https://zenodo.org/badge/.svg)](https://zenodo.org/badge/latestdoi/) -->
Expand Down Expand Up @@ -60,4 +61,4 @@ MUSICAv0 description and evaluation:
eprint = {https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2021MS002889},
year = {2022}
}
```
```
2 changes: 1 addition & 1 deletion lib/micm
Submodule micm updated 484 files
2 changes: 1 addition & 1 deletion lib/musica-core
2 changes: 1 addition & 1 deletion lib/tuv-x
Submodule tuv-x updated 39 files
+1 −1 CMakeLists.txt
+1 −1 README.md
+1 −1 cmake/dependencies.cmake
+1 −1 docs/source/conf.py
+47 −1 docs/source/user_guide.rst
+6 −1 docs/switcher.json
+50 −0 etc/derecho/README.md
+51 −0 etc/derecho/build_tuvx_derecho_gnu.sh
+49 −0 etc/derecho/build_tuvx_derecho_intel.sh
+2 −17 etc/modeling2/build_tuvx_modeling2_gnu.sh
+3 −1 src/cross_section.F90
+3 −1 src/cross_sections/hno3-oh_no2.F90
+3 −1 src/cross_sections/no2_tint.F90
+3 −1 src/cross_sections/o3_tint.F90
+3 −1 src/cross_sections/rono2.F90
+3 −1 src/cross_sections/temperature_based.F90
+3 −1 src/cross_sections/tint.F90
+3 −2 src/grids/equal_delta.F90
+37 −27 src/interpolate.F90
+2 −1 src/profiles/air.F90
+2 −1 src/profiles/extraterrestrial_flux.F90
+2 −1 src/profiles/from_csv_file.F90
+2 −1 src/profiles/o2.F90
+2 −1 src/profiles/o3.F90
+3 −1 src/quantum_yield.F90
+3 −1 src/quantum_yields/no2_tint.F90
+4 −2 src/quantum_yields/tint.F90
+8 −0 src/radiative_transfer/radiator_factory.F90
+1 −0 src/radiative_transfer/radiators/CMakeLists.txt
+6 −3 src/radiative_transfer/radiators/aerosol.F90
+116 −0 src/radiative_transfer/radiators/from_netcdf_file.F90
+3 −1 src/spectral_weight.F90
+13 −0 src/tuvx.F90
+ test/data/radiator.nc
+23 −0 test/data/radiators.from_netcdf_file.config.json
+2 −1 test/unit/cross_section/base.F90
+3 −1 test/unit/quantum_yield/base.F90
+1 −0 test/unit/radiator/CMakeLists.txt
+96 −0 test/unit/radiator/from_netcdf_file.F90
2 changes: 1 addition & 1 deletion musica-fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(netcdff IMPORTED_TARGET REQUIRED netcdf-fortran)

# Find MUSICA package
find_package(musica 0.3.0 REQUIRED)
find_package(musica 0.5.0 REQUIRED)

target_link_libraries(musica-fortran
PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion musica-fortran/src/micm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
target_sources(musica-fortran
PUBLIC
interface.F90
micm_mod.F90
)
22 changes: 0 additions & 22 deletions musica-fortran/src/micm/interface.F90

This file was deleted.

32 changes: 32 additions & 0 deletions musica-fortran/src/micm/micm_c_def.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
interface
function create_micm_c(config_path) bind(C, name="create_micm")
use iso_c_binding
implicit none
type(c_ptr) :: create_micm_c
character(len=1, kind=C_CHAR), intent(in) :: config_path(*)
end function

subroutine delete_micm_c(micm_t) bind(C, name="delete_micm")
use iso_c_binding
implicit none
type(c_ptr), value :: micm_t
end subroutine

function micm_create_solver_c(micm_t) bind(C, name="micm_create_solver")
use iso_c_binding
implicit none
integer(c_int) :: micm_create_solver_c ! TODO(jiwon) return value?
type(c_ptr), intent(in), value :: micm_t
end function

subroutine micm_solve_c(micm_t, temperature, pressure, time_step, concentrations, num_concentrations) bind(C, name="micm_solve")
use iso_c_binding
implicit none
type(c_ptr), intent(in), value :: micm_t
real(c_double), value :: temperature
real(c_double), value :: pressure
real(c_double), value :: time_step
real(c_double), dimension(*), intent(inout) :: concentrations
integer(c_size_t), value, intent(in) :: num_concentrations
end subroutine
end interface
60 changes: 60 additions & 0 deletions musica-fortran/src/micm/micm_mod.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module micm_mod
use iso_c_binding
implicit none

private
public :: micm_t

include "micm_c_def.F90"

type micm_t
private
type(c_ptr) :: ptr
contains
procedure :: create_solver => micm_create_solver
procedure :: solve => micm_solve
final :: delete_micm
end type

interface micm_t
procedure create_micm
end interface

contains
function create_micm(config_path)
type(micm_t) :: create_micm
character(len=*), intent(in) :: config_path
character(len=1, kind=C_CHAR) :: c_config_path(len_trim(config_path) + 1)
integer :: N, i

! Converting Fortran string to C string
N = len_trim(config_path)
do i = 1, N
c_config_path(i) = config_path(i:i)
end do
c_config_path(N + 1) = C_NULL_CHAR

create_micm%ptr = create_micm_c(c_config_path)
end function

subroutine delete_micm(this)
type(micm_t) :: this
call delete_micm_c(this%ptr)
end subroutine

integer function micm_create_solver(this)
class(micm_t), intent(in) :: this
micm_create_solver = micm_create_solver_c(this%ptr)
end function

subroutine micm_solve(this, temperature, pressure, time_step, concentrations, num_concentrations)
class(micm_t), intent(in) :: this
real(c_double), intent(in) :: temperature
real(c_double), intent(in) :: pressure
real(c_double), intent(in) :: time_step
real(c_double), dimension(*), intent(inout) :: concentrations
integer(c_size_t), intent(in) :: num_concentrations
call micm_solve_c(this%ptr, temperature, pressure, time_step, concentrations, num_concentrations)
end subroutine

end module
Loading

0 comments on commit 9897b8b

Please sign in to comment.