Skip to content

Commit

Permalink
Merge pull request #127 from NCAR/main
Browse files Browse the repository at this point in the history
MUSICA v0.2.0 updates
  • Loading branch information
K20shores authored Mar 14, 2023
2 parents c3bebba + ff001cc commit 7e3ad6f
Show file tree
Hide file tree
Showing 16 changed files with 401 additions and 230 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
!test/
!examples/
!etc/
!cmake/

# exclude generated code
libs/micm-collection/configured_tags/*
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create and publish a Docker image

on:
push:
branches: ['release']
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive

- name: Log in to the Container repository
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- name: build Docker image
run: docker build -t music-box-test . --build-arg TAG_ID=chapman
- name: run tests in container
run: docker run --name test-container -t music-box-test bash -c 'cd build; make test'
run: docker run --name test-container -t music-box-test bash -c 'cd /music-box/build; make test'
12 changes: 0 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
[submodule "libs/musica-core"]
path = libs/musica-core
url = https://github.com/NCAR/musica-core.git
[submodule "libs/micm"]
path = libs/micm
url = https://github.com/NCAR/micm.git
[submodule "libs/micm-preprocessor"]
path = libs/micm-preprocessor
url = https://github.com/NCAR/micm-preprocessor.git
[submodule "libs/micm-collection"]
path = libs/micm-collection
url = https://github.com/NCAR/micm-collection.git
[submodule "libs/music-box-interactive"]
path = libs/music-box-interactive
url = https://github.com/NCAR/music-box-interactive.git
[submodule "libs/camp"]
path = libs/camp
url = https://github.com/open-atmos/camp.git
146 changes: 4 additions & 142 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,161 +1,23 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.21)
set(CMAKE_USER_MAKE_RULES_OVERRIDE "SetDefaults.cmake")
project(MUSICA)
project(musicbox)
enable_language(Fortran)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

################################################################################
# options

################################################################################
# NetCDF library

find_path(NETCDF_INCLUDE_DIR netcdf.mod NETCDF.mod
DOC "NetCDF include directory (must contain netcdf.mod)"
PATHS
$ENV{NETCDF_HOME}/include
/usr/lib/gfortran/modules
/usr/lib64/gfortran/modules
/opt/local/include)
find_library(NETCDF_C_LIB netcdf
DOC "NetCDF C library"
PATHS
$ENV{NETCDF_HOME}/lib
$ENV{NETCDF_HOME}/lib64
opt/local/lib)
find_library(NETCDF_FORTRAN_LIB netcdff
DOC "NetCDF Fortran library"
PATHS
$ENV{NETCDF_HOME}/lib
$ENV{NETCDF_HOME}/lib64
/opt/local/lib)
set(NETCDF_LIBS ${NETCDF_C_LIB})
if(NETCDF_FORTRAN_LIB)
set(NETCDF_LIBS ${NETCDF_LIBS} ${NETCDF_FORTRAN_LIB})
endif()
include_directories(${NETCDF_INCLUDE_DIR})

################################################################################
# json-fortran library

find_path(JSON_INCLUDE_DIR json_module.mod
DOC "json-fortran include directory (must include json_*.mod files)"
PATHS
$ENV{JSON_FORTRAN_HOME}/lib
/opt/local/lib
/usr/local/lib
/usr/local/lib64)
find_library(JSON_LIB jsonfortran
DOC "json-fortran library"
PATHS
$ENV{JSON_FORTRAN_HOME}/lib
/opt/local/lib
/usr/local/lib
/usr/local/lib64)
include_directories(${JSON_INCLUDE_DIR})

################################################################################
# GSL

find_path(GSL_INCLUDE_DIR gsl/gsl_math.h
DOC "GSL include directory (must have gsl/ subdir)"
PATHS $ENV{GSL_HOME}/include /opt/local/include)
find_library(GSL_LIB gsl
DOC "GSL library"
PATHS $ENV{GSL_HOME}/lib /opt/local/lib)
find_library(GSL_CBLAS_LIB gslcblas
DOC "GSL CBLAS library"
PATHS $ENV{GSL_HOME}/lib /opt/local/lib)
find_library(M_LIB m
DOC "standard C math library")
set(GSL_LIBS ${GSL_LIB} ${GSL_CBLAS_LIB} ${M_LIB})
include_directories(${GSL_INCLUDE_DIR})

################################################################################
# SUNDIALS

find_path(SUITE_SPARSE_INCLUDE_DIR klu.h
DOC "SuiteSparse include directory (must have klu.h)"
PATHS $ENV{SUITE_SPARSE_HOME}/include $ENV{SUNDIALS_HOME}/include
/opt/local/include /usr/local/include)
find_library(SUITE_SPARSE_KLU_LIB klu
DOC "SuiteSparse klu library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
find_library(SUITE_SPARSE_AMD_LIB amd
DOC "SuiteSparse amd library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
find_library(SUITE_SPARSE_BTF_LIB btf
DOC "SuiteSparse btf library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
find_library(SUITE_SPARSE_COLAMD_LIB colamd
DOC "SuiteSparse colamd library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
find_library(SUITE_SPARSE_CONFIG_LIB suitesparseconfig
DOC "SuiteSparse config library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
find_path(SUNDIALS_INCLUDE_DIR cvode/cvode.h
DOC "SUNDIALS include directory (must have cvode/, sundials/, nvector/ subdirs)"
PATHS $ENV{SUNDIALS_HOME}/include /opt/local/include /usr/local/include)
find_library(SUNDIALS_NVECSERIAL_LIB sundials_nvecserial
DOC "SUNDIALS serial vector library"
PATHS $ENV{SUNDIALS_HOME}/lib /opt/local/lib /usr/local/lib)
find_library(SUNDIALS_CVODE_LIB sundials_cvode
DOC "SUNDIALS CVODE library"
PATHS $ENV{SUNDIALS_HOME}/lib /opt/local/lib /usr/local/lib)
find_library(SUNDIALS_KLU_LIB sundials_sunlinsolklu
DOC "SUNDIALS KLU library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
find_library(SUNDIALS_SUNMATRIX_SPARSE_LIB sundials_sunmatrixsparse
DOC "SUNDIALS SUNMatrixSparse library"
PATHS $ENV{SUITE_SPARSE_HOME}/lib $ENV{SUNDIALS_HOME}/lib
/opt/local/lib /usr/local/lib)
set(SUNDIALS_LIBS ${SUNDIALS_NVECSERIAL_LIB} ${SUNDIALS_CVODE_LIB}
${SUNDIALS_KLU_LIB} ${SUNDIALS_SUNMATRIX_SPARSE_LIB} ${SUITE_SPARSE_KLU_LIB}
${SUITE_SPARSE_COLAMD_LIB} ${SUITE_SPARSE_AMD_LIB} ${SUITE_SPARSE_BTF_LIB}
${SUITE_SPARSE_CONFIG_LIB})
include_directories(${SUNDIALS_INCLUDE_DIR} ${SUITE_SPARSE_INCLUDE_DIR})

################################################################################
# CAMP library

find_path(CAMP_INCLUDE_DIR camp_core.mod
DOC "CAMP include directory (must include camp_*.mod files)"
PATHS
/opt/local/lib
/usr/local/lib
/usr/local/lib64)
find_library(CAMP_LIB camp
DOC "CAMP library"
PATHS
/opt/local/lib
/usr/local/lib
/usr/local/lib64)
include_directories(${CAMP_INCLUDE_DIR})

################################################################################
# Create a directory to hold input data

add_custom_target(data-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/data)

################################################################################
# MUSICA library

add_subdirectory(libs/musica-core/src)
include_directories(${CMAKE_BINARY_DIR}/libs/musica-core/src)

################################################################################
# MICM library
# Dependencies

add_subdirectory(libs/micm/src)
include_directories(${CMAKE_BINARY_DIR}/libs/micm/src)
include(cmake/dependencies.cmake)

################################################################################
# MusicBox application
Expand Down
86 changes: 20 additions & 66 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:33
FROM fedora:37

RUN dnf -y update \
&& dnf -y install \
Expand All @@ -13,30 +13,18 @@ RUN dnf -y update \
cmake \
make \
wget \
python \
git \
postgresql-devel \
python3 \
python3-pip \
texlive-scheme-basic \
'tex(type1cm.sty)' \
'tex(type1ec.sty)' \
dvipng \
git \
nodejs \
ncview \
&& dnf clean all

# python modules needed in scripts
RUN dnf -y install python3-pandas

RUN pip3 install requests numpy scipy matplotlib ipython jupyter nose Django pillow \
django-crispy-forms pyvis django-cors-headers drf-yasg

# Build the SuiteSparse libraries for sparse matrix support
RUN curl -LO http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-5.1.0.tar.gz \
&& tar -zxvf SuiteSparse-5.1.0.tar.gz \
&& export CXX=/usr/bin/cc \
&& cd SuiteSparse \
&& make install INSTALL=/usr/local BLAS="-L/lib64 -lopenblas"
&& make -j 8 install INSTALL=/usr/local BLAS="-L/lib64 -lopenblas"

# install json-fortran
RUN curl -LO https://github.com/jacobwilliams/json-fortran/archive/8.2.0.tar.gz \
Expand All @@ -46,24 +34,15 @@ RUN curl -LO https://github.com/jacobwilliams/json-fortran/archive/8.2.0.tar.gz
&& mkdir build \
&& cd build \
&& cmake -D SKIP_DOC_GEN:BOOL=TRUE .. \
&& make install
&& make -j 8 install

# copy the MusicBox code
COPY . /music-box/

# move the change mechanism script to the root folder
RUN cp /music-box/etc/change_mechanism.sh /

# move the example configurations to the build folder
RUN mkdir /build \
&& cp -r /music-box/examples /build/examples

# nodejs modules needed Mechanism-To-Code
RUN cd /music-box/libs/micm-preprocessor; \
npm install
# copy the interactive server code
COPY . /music-box

# Install a modified version of CVODE
RUN tar -zxvf /music-box/libs/camp/cvode-3.4-alpha.tar.gz \
RUN mkdir cvode_build \
&& cd cvode_build \
&& tar -zxvf /music-box/libs/camp/cvode-3.4-alpha.tar.gz \
&& cd cvode-3.4-alpha \
&& mkdir build \
&& cd build \
Expand All @@ -90,38 +69,13 @@ RUN mkdir camp_build \
/music-box/libs/camp \
&& make

# command line arguments
ARG TAG_ID=false

# get a MICM mechanism if one has been specified
RUN if [ "$TAG_ID" = "false" ] ; then \
echo "No mechanism specified" ; else \
echo "Grabbing mechanism $TAG_ID" \
&& cd /music-box/libs/micm-preprocessor \
&& nohup bash -c "node combined.js &" && sleep 4 \
&& mkdir /data \
&& cd /music-box/libs/micm-collection \
&& if [ "$TAG_ID" = "chapman" ] ; then \
python3 preprocess_tag.py -c configured_tags/$TAG_ID/config.json -p localhost:3000 \
&& python3 stage_tag.py -source_dir_kinetics configured_tags/$TAG_ID/output -target_dir_data /data \
; else \
echo "Only Chapman chemistry is currently available for MusicBox-MICM" \
&& exit 1 \
; fi \
; fi

# build the model
RUN cd /build \
&& export JSON_FORTRAN_HOME="/usr/local/jsonfortran-gnu-8.2.0" \
&& cmake -D CAMP_INCLUDE_DIR="/camp_build/include" \
-D CAMP_LIB="/camp_build/lib/libcamp.a" \
/music-box \
&& make

# Prepare the music-box-interactive web server
RUN mv music-box/libs/music-box-interactive .
ENV MUSIC_BOX_BUILD_DIR=/build

EXPOSE 8000

CMD ["python3", "music-box-interactive/interactive/manage.py", "runserver", "0.0.0.0:8000" ]
# build music-box
RUN cd music-box \
&& mkdir build \
&& cd build \
&& export FC=gfortran \
&& export JSON_FORTRAN_HOME="/usr/local/jsonfortran-gnu-8.2.0" \
&& cmake -D CAMP_INCLUDE_DIR="/camp_build/include" \
-D CAMP_LIB="/camp_build/lib/libcamp.a" \
.. \
&& make -j 8
Loading

0 comments on commit 7e3ad6f

Please sign in to comment.