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

bugfix: dockerfile build and CI error reporting #494

Merged
merged 9 commits into from
Aug 9, 2024
2 changes: 2 additions & 0 deletions .github/workflows/ci_test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [pull_request,workflow_dispatch]

env:
TEST_TAG: dtcenter/ccpp-scm:test
PR_NUMBER: ${{ github.event.number }}

jobs:
docker:
Expand All @@ -22,6 +23,7 @@ jobs:
file: docker/Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
build-args: PR_NUMBER=${{ github.event.number }}
- name: Test
run: |
mkdir $HOME/output
Expand Down
2 changes: 1 addition & 1 deletion ccpp/physics
86 changes: 46 additions & 40 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
FROM debian:12
MAINTAINER Michael Kavulich <[email protected]>
LABEL maintainer="Michael Kavulich <[email protected]>"

# Set up base OS environment
# arguments that can be passed in
ARG PR_NUMBER

# Set up base OS environment
RUN apt-get -y update

# Get "essential" tools and libraries
RUN apt-get -y install build-essential \
&& apt-get -y install cmake curl git file gfortran-12 ksh m4 python3 tcsh time wget vim \
&& apt-get -y install cmake cmake-curses-gui curl git file gfortran-12 ksh m4 python3 tcsh time wget vim emacs-nox \
&& apt-get -y install libnetcdf-pnetcdf-19 libnetcdff7 libnetcdf-dev libnetcdff-dev libxml2 \
&& apt-get -y install python3-pip python3.11-venv
&& apt-get -y install python3-pip python3.11-venv python3-netcdf4 \
&& apt-get -y install openmpi-bin libopenmpi-dev
RUN ln -s /usr/bin/python3 /usr/bin/python

MAINTAINER Grant Firl <[email protected]> or Michael Kavulich <[email protected]>
# Set up python needed packages, preferred Docker method is apt-get but
# f90nml can't be installed for debian that way
RUN pip install f90nml --break-system-packages

#Compiler environment variables
ENV CC /usr/bin/gcc
ENV FC /usr/bin/gfortran
ENV CXX /usr/bin/g++
ENV F77 /usr/bin/gfortran
ENV F90 /usr/bin/gfortran
ENV CC=/usr/bin/gcc
ENV FC=/usr/bin/gfortran
ENV CXX=/usr/bin/g++
ENV F77=/usr/bin/gfortran
ENV F90=/usr/bin/gfortran

# Other necessary environment variables
ENV LD_LIBRARY_PATH /usr/lib/
ENV LD_LIBRARY_PATH=/usr/lib/

# Set up unpriviledged user account, set up user home space and make sure user has permissions on all stuff in /comsoftware
RUN groupadd comusers -g 9999 \
Expand All @@ -32,57 +38,63 @@ RUN groupadd comusers -g 9999 \
&& chown -R comuser:comusers /comsoftware \
&& chmod -R 6755 /comsoftware

# Link version-specific aliases (python3 will be created later with virtual environment)
RUN ln -s ~comuser/.venv/bin/python3 /usr/local/bin/python
RUN ln -s /usr/bin/gfortran-12 /usr/bin/gfortran

# all root steps completed above, now continue below as regular userID comuser
USER comuser
WORKDIR /home

# Build NCEP libraries we need for SCM

ENV NCEPLIBS_DIR /comsoftware/nceplibs
ENV NCEPLIBS_DIR=/comsoftware/nceplibs

RUN mkdir -p $NCEPLIBS_DIR/src && cd $NCEPLIBS_DIR/src \
&& git clone -b v2.4.1 --recursive https://github.com/NOAA-EMC/NCEPLIBS-bacio \
&& mkdir NCEPLIBS-bacio/build && cd NCEPLIBS-bacio/build \
&& cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
&& make VERBOSE=1 \
&& make install
&& make VERBOSE=1 -j \
&& make install

RUN cd $NCEPLIBS_DIR/src \
&& git clone -b v2.3.3 --recursive https://github.com/NOAA-EMC/NCEPLIBS-sp \
&& mkdir NCEPLIBS-sp/build && cd NCEPLIBS-sp/build \
&& cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
&& make VERBOSE=1 \
&& make VERBOSE=1 -j \
&& make install

RUN cd $NCEPLIBS_DIR/src \
&& git clone -b v2.11.0 --recursive https://github.com/NOAA-EMC/NCEPLIBS-w3emc \
&& mkdir NCEPLIBS-w3emc/build && cd NCEPLIBS-w3emc/build \
&& cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
&& make VERBOSE=1 \
&& make VERBOSE=1 -j \
&& make install

ENV bacio_ROOT /comsoftware/nceplibs
ENV sp_ROOT /comsoftware/nceplibs
ENV w3emc_ROOT /comsoftware/nceplibs
ENV bacio_ROOT=/comsoftware/nceplibs
ENV sp_ROOT=/comsoftware/nceplibs
ENV w3emc_ROOT=/comsoftware/nceplibs

# Obtain CCPP SCM source code, build code, and download static data
RUN if [ -z "$PR_NUMBER" ]; then \
cd /comsoftware \
&& git clone --recursive -b main https://github.com/NCAR/ccpp-scm; \
else \
cd /comsoftware \
&& git clone https://github.com/NCAR/ccpp-scm \
&& cd ccpp-scm \
&& git fetch origin pull/${PR_NUMBER}/head:test_pr \
&& git checkout test_pr \
&& git submodule update --init --recursive; \
fi

RUN mkdir /comsoftware/ccpp-scm/scm/bin \
&& cd /comsoftware/ccpp-scm/scm/bin \
&& cmake ../src \
&& make -j

# Obtain CCPP SCM source code and static data, build code
RUN cd /comsoftware \
&& git clone --recursive -b main https://github.com/NCAR/ccpp-scm \
&& cd /comsoftware/ccpp-scm/ \
RUN cd /comsoftware/ccpp-scm/ \
&& ./contrib/get_all_static_data.sh \
&& ./contrib/get_thompson_tables.sh \
&& cd /comsoftware/ccpp-scm/scm \
&& mkdir bin \
&& cd bin \
&& cmake ../src \
&& make -j4
&& ./contrib/get_thompson_tables.sh

# The analysis scripts have options for using LaTeX when making figure labels.
# If you would like to install LaTeK, uncomment the section below.
# If you would like to install LaTeK, uncomment the section below.
# Note: This will increase the image size by 1 GB.
#USER root
#RUN yum -y update \
Expand All @@ -96,9 +108,3 @@ ENV SCM_ROOT=/comsoftware/ccpp-scm/

# For interactive use, vim mouse settings are infuriating
RUN echo "set mouse=" > ~/.vimrc

# Set up python virtual environment and install needed packages
ENV VIRTUAL_ENV=~/.venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip3 install f90nml==1.4.4 netcdf4==1.6.5
19 changes: 9 additions & 10 deletions scm/src/CCPP_typedefs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ module CCPP_typedefs
real (kind=kind_phys), pointer :: qs_lay(:,:) => null() !<
real (kind=kind_phys), pointer :: q_lay(:,:) => null() !<
real (kind=kind_phys), pointer :: deltaZ(:,:) => null() !<
real (kind=kind_phys), pointer :: deltaZc(:,:) => null() !<
real (kind=kind_phys), pointer :: deltaP(:,:) => null() !<
real (kind=kind_phys), pointer :: deltaZc(:,:) => null() !<
real (kind=kind_phys), pointer :: deltaP(:,:) => null() !<
real (kind=kind_phys), pointer :: cloud_overlap_param(:,:) => null() !< Cloud overlap parameter
real (kind=kind_phys), pointer :: cnv_cloud_overlap_param(:,:) => null() !< Convective cloud overlap parameter
real (kind=kind_phys), pointer :: precip_overlap_param(:,:) => null() !< Precipitation overlap parameter
Expand All @@ -373,12 +373,12 @@ module CCPP_typedefs
real (kind=kind_phys), pointer :: cld_rwp(:,:) => null() !< Cloud rain water path
real (kind=kind_phys), pointer :: cld_rerain(:,:) => null() !< Cloud rain effective radius
real (kind=kind_phys), pointer :: precip_frac(:,:) => null() !< Precipitation fraction
real (kind=kind_phys), pointer :: cld_cnv_frac(:,:) => null() !< SGS convective cloud fraction
real (kind=kind_phys), pointer :: cld_cnv_frac(:,:) => null() !< SGS convective cloud fraction
real (kind=kind_phys), pointer :: cld_cnv_lwp(:,:) => null() !< SGS convective cloud liquid water path
real (kind=kind_phys), pointer :: cld_cnv_reliq(:,:) => null() !< SGS convective cloud liquid effective radius
real (kind=kind_phys), pointer :: cld_cnv_iwp(:,:) => null() !< SGS convective cloud ice water path
real (kind=kind_phys), pointer :: cld_cnv_reice(:,:) => null() !< SGS convective cloud ice effecive radius
real (kind=kind_phys), pointer :: cld_pbl_lwp(:,:) => null() !< SGS PBL cloud liquid water path
real (kind=kind_phys), pointer :: cld_pbl_lwp(:,:) => null() !< SGS PBL cloud liquid water path
real (kind=kind_phys), pointer :: cld_pbl_reliq(:,:) => null() !< SGS PBL cloud liquid effective radius
real (kind=kind_phys), pointer :: cld_pbl_iwp(:,:) => null() !< SGS PBL cloud ice water path
real (kind=kind_phys), pointer :: cld_pbl_reice(:,:) => null() !< SGS PBL cloud ice effecive radius
Expand All @@ -390,7 +390,7 @@ module CCPP_typedefs
real (kind=kind_phys), pointer :: fluxswDOWN_allsky(:,:) => null() !< RRTMGP downward shortwave all-sky flux profile
real (kind=kind_phys), pointer :: fluxswUP_clrsky(:,:) => null() !< RRTMGP upward shortwave clr-sky flux profile
real (kind=kind_phys), pointer :: fluxswDOWN_clrsky(:,:) => null() !< RRTMGP downward shortwave clr-sky flux profile
real (kind=kind_phys), pointer :: sfc_emiss_byband(:,:) => null() !<
real (kind=kind_phys), pointer :: sfc_emiss_byband(:,:) => null() !<
real (kind=kind_phys), pointer :: sec_diff_byband(:,:) => null() !<
real (kind=kind_phys), pointer :: sfc_alb_nir_dir(:,:) => null() !<
real (kind=kind_phys), pointer :: sfc_alb_nir_dif(:,:) => null() !<
Expand Down Expand Up @@ -888,7 +888,7 @@ subroutine gfs_interstitial_setup_tracers(Interstitial, Model)
Interstitial%nvdiff = Interstitial%nvdiff + 1
ENDIF
if (Model%me == Model%master) write(0,*) 'nssl_settings2: nvdiff,ntrac = ', Interstitial%nvdiff, Model%ntrac

elseif (Model%imp_physics == Model%imp_physics_wsm6) then
Interstitial%nvdiff = Model%ntrac -3
if (Model%satmedmf) Interstitial%nvdiff = Interstitial%nvdiff + 1
Expand Down Expand Up @@ -965,8 +965,7 @@ subroutine gfs_interstitial_setup_tracers(Interstitial, Model)
Interstitial%nvdiff = 9
endif
else
write(0,*) "Selected microphysics scheme is not supported when coupling with chemistry"
stop
error stop "Selected microphysics scheme is not supported when coupling with chemistry"
endif
if (Interstitial%trans_aero) Interstitial%nvdiff = Interstitial%nvdiff + Model%ntchm
if (Model%ntke > 0) Interstitial%nvdiff = Interstitial%nvdiff + 1 ! adding tke to the list
Expand Down Expand Up @@ -1419,11 +1418,11 @@ subroutine gfs_interstitial_phys_reset (Interstitial, Model)
! Use same logic in UFS to reset Thompson extended diagnostics
Interstitial%ext_diag_thompson_reset = Interstitial%max_hourly_reset
!
! Frequency flag for computing the full radar reflectivity (water coated ice)
! Frequency flag for computing the full radar reflectivity (water coated ice)
if (Model%nsfullradar_diag<0) then
Interstitial%fullradar_diag = .true.
else
Interstitial%fullradar_diag = (Model%kdt == 1 .or. mod(Model%kdt, nint(Model%nsfullradar_diag/Model%dtp)) == 0)
Interstitial%fullradar_diag = (Model%kdt == 1 .or. mod(Model%kdt, nint(Model%nsfullradar_diag/Model%dtp)) == 0)
end if
!

Expand Down
Loading
Loading