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

Bump base image to one with Ubuntu version 20.04 #364

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
command: |
git submodule init
git submodule update
- run: DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=plain BUILD_FROM_INTERMEDIATE=y make build build_debug build_serialize
- run: DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=plain BUILD_FROM_INTERMEDIATE=y make build build_debug
- restore_cache:
keys:
- v1.4-{{ checksum "requirements.txt"}}
Expand Down
28 changes: 14 additions & 14 deletions FV3/gfsphysics/physics/samfdeepcnv.f
Original file line number Diff line number Diff line change
Expand Up @@ -1547,22 +1547,22 @@ subroutine samfdeepcnv(im,ix,km,delt,itc,ntc,ntk,ntr,delp,
enddo
enddo
do i = 1, im
betamn = betas
if(islimsk(i) == 1) betamn = betal
if(ntk > 0) then
betamx = betamn + dbeta
if(tkemean(i) > tkemx) then
beta = betamn
else if(tkemean(i) < tkemn) then
beta = betamx
if(cnvflg(i)) then
betamn = betas
if(islimsk(i) == 1) betamn = betal
if(ntk > 0) then
betamx = betamn + dbeta
if(tkemean(i) > tkemx) then
beta = betamn
else if(tkemean(i) < tkemn) then
beta = betamx
else
tem = (betamx - betamn) * (tkemean(i) - tkemn)
beta = betamx - tem / dtke
endif
else
tem = (betamx - betamn) * (tkemean(i) - tkemn)
beta = betamx - tem / dtke
beta = betamn
endif
else
beta = betamn
endif
if(cnvflg(i)) then
dz = (sumx(i)+zi(i,1))/float(kbcon(i))
tem = 1./float(kbcon(i))
xlamd(i) = (1.-beta**tem)/dz
Expand Down
31 changes: 10 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ OTHER_MOUNTS ?=

# base images w/ or w/o CUDA
ifeq ($(CUDA),n)
BASE_IMAGE ?=ubuntu:18.04
DEP_TAG_NAME ?=gnu7-mpich314-nocuda
# Note this BASE_IMAGE version is the same as the one used in the
# fv3net prognostic_run image. It corresponds to an image with Ubuntu
# version 20.04.
BASE_IMAGE ?=ubuntu@sha256:9101220a875cee98b016668342c489ff0674f247f6ca20dfc91b91c0f28581ae
DEP_TAG_NAME ?=gnu9-mpich314-nocuda
else
BASE_IMAGE ?=nvidia/cuda:10.2-devel-ubuntu18.04
DEP_TAG_NAME ?=gnu7-mpich314-cuda102
Expand All @@ -24,21 +27,19 @@ BUILD_ARGS += --build-arg BASE_IMAGE=$(BASE_IMAGE)
# image names (use XXX_IMAGE=<name> make <target> to override)
COMPILED_TAG_NAME ?=$(DEP_TAG_NAME)
COMPILED_IMAGE ?= $(GCR_URL)/$(COMPILE_TARGET):$(COMPILED_TAG_NAME)
SERIALIZE_IMAGE ?= $(GCR_URL)/$(COMPILE_TARGET):$(COMPILED_TAG_NAME)-serialize
EMULATION_IMAGE ?= $(GCR_URL)/$(COMPILE_TARGET):$(COMPILED_TAG_NAME)-emulation
ENVIRONMENT_IMAGE ?= $(GCR_URL)/$(ENVIRONMENT_TARGET):$(ENVIRONMENT_TAG_NAME)
MPI_IMAGE ?= $(GCR_URL)/mpi-build:$(DEP_TAG_NAME)
FMS_IMAGE ?= $(GCR_URL)/fms-build:$(DEP_TAG_NAME)
ESMF_IMAGE ?= $(GCR_URL)/esmf-build:$(DEP_TAG_NAME)
SERIALBOX_IMAGE ?= $(GCR_URL)/serialbox-build:$(DEP_TAG_NAME)

# used to shorten build times in CircleCI
ifeq ($(BUILD_FROM_INTERMEDIATE),y)
BUILD_ARGS += --build-arg FMS_IMAGE=$(FMS_IMAGE) --build-arg ESMF_IMAGE=$(ESMF_IMAGE) --build-arg SERIALBOX_IMAGE=$(SERIALBOX_IMAGE) --build-arg MPI_IMAGE=$(MPI_IMAGE)
BUILD_ARGS += --build-arg FMS_IMAGE=$(FMS_IMAGE) --build-arg ESMF_IMAGE=$(ESMF_IMAGE) --build-arg MPI_IMAGE=$(MPI_IMAGE)
endif

.PHONY: help build build_environment build_compiled build_serialize build_debug
.PHONY: build_deps push_deps pull_deps enter enter_serialize test update_circleci_reference clean
.PHONY: help build build_environment build_compiled build_debug
.PHONY: build_deps push_deps pull_deps enter test update_circleci_reference clean

help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
Expand All @@ -60,41 +61,29 @@ build_compiled: ## build production container image
build_debug: ## build container image for debugging
COMPILED_TAG_NAME=$(COMPILED_TAG_NAME)-debug COMPILE_OPTION="REPRO=\\\nDEBUG=Y" $(MAKE) build

build_serialize: ## build container image for serialization
BUILD_ARGS="$(BUILD_ARGS) --build-arg serialize=true" \
COMPILED_IMAGE=$(SERIALIZE_IMAGE) \
$(MAKE) build_compiled

build_deps: ## build container images of dependnecies (FMS, ESMF, SerialBox)
build_deps: ## build container images of dependnecies (FMS, ESMF)
docker build -f $(DOCKERFILE) -t $(MPI_IMAGE) $(BUILD_ARGS) --target fv3gfs-mpi .
docker build -f $(DOCKERFILE) -t $(FMS_IMAGE) $(BUILD_ARGS) --target fv3gfs-fms .
docker build -f $(DOCKERFILE) -t $(ESMF_IMAGE) $(BUILD_ARGS) --target fv3gfs-esmf .
docker build -f $(DOCKERFILE) -t $(SERIALBOX_IMAGE) $(BUILD_ARGS) --target fv3gfs-environment-serialbox .

push_image_%:
docker tag $(GCR_URL)/$*:$(DEP_TAG_NAME) $(GCR_URL)/$*:$(DEP_TAG_NAME)-$(COMMIT_SHA)
docker push $(GCR_URL)/$*:$(DEP_TAG_NAME)
docker push $(GCR_URL)/$*:$(DEP_TAG_NAME)-$(COMMIT_SHA)

## push container images of dependencies to GCP
push_deps: push_image_mpi-build push_image_fms-build push_image_esmf-build push_image_serialbox-build
push_deps: push_image_mpi-build push_image_fms-build push_image_esmf-build

pull_deps: ## pull container images of dependencies from GCP (for faster builds)
docker pull $(MPI_IMAGE)
docker pull $(FMS_IMAGE)
docker pull $(ESMF_IMAGE)
docker pull $(SERIALBOX_IMAGE)

enter: ## run and enter production container for development
docker run --rm \
-v $(shell pwd)/FV3:/FV3 $(OTHER_MOUNTS) \
-w /FV3 -it $(COMPILED_IMAGE) bash

enter_serialize: ## run and enter serialization container for development
docker run --rm \
-v $(shell pwd)/FV3:/FV3/original $(OTHER_MOUNTS) \
-w /FV3 -it $(SERIALIZE_IMAGE) bash

test: ## run tests (set COMPILED_TAG_NAME to override default)
pytest tests/pytest --capture=no --verbose --refdir $(shell pwd)/tests/pytest/reference/circleci --image_version $(COMPILED_TAG_NAME)

Expand Down
96 changes: 9 additions & 87 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
ARG serialize=false
ARG fv3_build_env_tag=standard
ARG BASE_IMAGE
ARG MPI_IMAGE=fv3gfs-mpi
ARG FMS_IMAGE=fv3gfs-fms
ARG ESMF_IMAGE=fv3gfs-esmf
ARG SERIALBOX_IMAGE=fv3gfs-environment-serialbox

FROM $BASE_IMAGE AS fv3gfs-mpi

Expand All @@ -25,7 +22,8 @@ RUN wget -q http://www.mpich.org/static/downloads/3.1.4/mpich-3.1.4.tar.gz && \
FROM $MPI_IMAGE AS mpi_image

FROM $BASE_IMAGE AS fv3gfs-environment
RUN apt-get update && apt-get install -y \
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata && \
apt-get install -y \
wget \
gcc \
libtool-bin \
Expand Down Expand Up @@ -55,53 +53,6 @@ RUN git config --global http.sslverify false && \
git checkout 3da51e139d5cd731c9fc27f39d88cb4e1328212b && \
echo "y" | ./make_ncep_libs.sh -s linux -c gnu -d /opt/NCEPlibs -o 1

##
## Setup environment for Serialbox
##---------------------------------------------------------------------------------
FROM fv3gfs-environment as fv3gfs-environment-serialbox
# set TZ
ENV DEBIAN_FRONTEND=noninteractive TZ=US/Pacific
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
spencerkclark marked this conversation as resolved.
Show resolved Hide resolved

# install dependencies for serialbox
RUN apt-get update && apt-get install -y \
libssl-dev \
clang \
clang-format \
clang-tidy \
python3-numpy \
python3-nose \
python3-sphinx

# RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.18.3/cmake-3.18.3-Linux-x86_64.sh && \
# chmod +x ./cmake-3.18.3-Linux-x86_64.sh && \
# cmake-3.18.3-Linux-x86_64.sh
spencerkclark marked this conversation as resolved.
Show resolved Hide resolved

RUN wget https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3.tar.gz && \
tar xzf cmake-3.17.3.tar.gz && \
cd cmake-3.17.3 && \
./bootstrap && make -j4 && make install

# Install headers from the Boost library
RUN wget -q https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.tar.gz && \
tar xzf boost_1_74_0.tar.gz && \
cd boost_1_74_0 && \
cp -r boost /usr/include/ && cd /

# install serialbox from source
COPY serialbox serialbox
RUN cd serialbox && \
mkdir build && \
cd build && \
cmake -DSERIALBOX_USE_NETCDF=ON -DSERIALBOX_ENABLE_FORTRAN=ON \
-DSERIALBOX_TESTING=ON ../ && \
make -j16 && \
make test && \
make install

# setup link for backwards comatibility
RUN ln -s /serialbox /serialbox2

## Build FMS
##---------------------------------------------------------------------------------
FROM fv3gfs-environment AS fv3gfs-fms
Expand Down Expand Up @@ -140,9 +91,9 @@ RUN git clone -b ESMF_8_0_0 --depth 1 https://git.code.sf.net/p/esmf/esmf $ESMF_
make install && \
make installcheck

## Copy FV3GFS sources for non-serialize image
## Copy FV3GFS sources
##---------------------------------------------------------------------------------
FROM $BASE_IMAGE AS fv3gfs-src-serialize-false
FROM $BASE_IMAGE AS fv3gfs-src

ARG compile_option
ARG configure_file=configure.fv3.gnu_docker
Expand All @@ -168,55 +119,28 @@ RUN cp /FV3/conf/$configure_file \

COPY FV3/atmos_cubed_sphere /FV3/atmos_cubed_sphere

## Convert FV3GFS sources for serialize image
##---------------------------------------------------------------------------------
FROM $SERIALBOX_IMAGE AS fv3gfs-src-serialize-true

ARG compile_option
ARG configure_file=configure.fv3.gnu_docker_serialize

ENV SERIALBOX_OUTDIR=/FV3
ENV FV3_BASE=/FV3/original

COPY --from=fv3gfs-src-serialize-false /FV3 $FV3_BASE
COPY --from=fv3gfs-src-serialize-false /stochastic_physics $(FV3_BASE)/../stochastic_physics

# copy appropriate configuration file to configure.fv3
RUN cp $FV3_BASE/conf/$configure_file \
$FV3_BASE/conf/configure.fv3 && \
if [ ! -z $compile_option ]; then sed -i "33i $compile_option" \
$FV3_BASE/conf/configure.fv3; fi && \
cd $FV3_BASE && \
make serialize_preprocess


## Convert FV3GFS sources for emulation image
##---------------------------------------------------------------------------------

FROM fv3gfs-src-serialize-$serialize AS fv3gfs-sources
FROM fv3gfs-src AS fv3gfs-sources

FROM $FMS_IMAGE AS fms_image
FROM $ESMF_IMAGE AS esmf_image
FROM $SERIALBOX_IMAGE AS serialbox_image

FROM fv3gfs-environment AS fv3gfs-environment-standard

## Build FV3 executable in its own image
##---------------------------------------------------------------------------------
FROM fv3gfs-environment-${fv3_build_env_tag} AS fv3gfs-build
FROM fv3gfs-environment-standard AS fv3gfs-build

ENV ESMFMKFILE=/usr/local/esmf/lib/esmf.mk

ENV SERIALBOX_DIR=/serialbox \
SERIALBOX_OUTDIR=/FV3 \
FMS_DIR=/FMS \
ENV FMS_DIR=/FMS \
ESMF_DIR=/usr/local/esmf

ENV ESMF_INC="-I/usr/local/esmf/include" \
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ESMF_DIR}/lib:${FMS_DIR}/libFMS/.libs/:${SERIALBOX_DIR}/lib \
PPSER_PY=$(SERIALBOX_DIR)/python/pp_ser/pp_ser.py
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ESMF_DIR}/lib:${FMS_DIR}/libFMS/.libs

COPY --from=serialbox_image /serialbox/install $SERIALBOX_DIR
COPY --from=fms_image /FMS $FMS_DIR
COPY --from=esmf_image /usr/local/esmf $ESMF_DIR

Expand All @@ -235,9 +159,7 @@ FROM fv3gfs-build AS fv3gfs-compiled

RUN apt-get update && apt-get install -y \
python3 \
python3-pip && \
ln -s /bin/python3 /bin/python && \
ln -s /bin/pip3 /bin/pip
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without removing this line creating the symlink for pip3 fails since pip already exists in /bin:

ln: failed to create symbolic link '/bin/pip': File exists

I don't believe these symlinks are needed in general, so I removed the one above as well.

python3-pip
# install python packages needed to convert to netcdf data
RUN pip3 install --upgrade setuptools pip && \
pip3 install --no-cache-dir pyyaml xarray==0.16.2 f90nml==1.1.0 netCDF4
Expand Down
37 changes: 37 additions & 0 deletions tests/pytest/reference/circleci/baroclinic-debug/md5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
131fab4e3cd1feae7cb6bdaff881e725 atmos_4xdaily_fine_inst.tile1.nc
fe45eab4a5c25ec93a5a348ee08881a0 atmos_4xdaily_fine_inst.tile2.nc
fad54c07bf8692b0bb1296a189306dff atmos_4xdaily_fine_inst.tile3.nc
bdf349ecd9d8065fb7bc27d69b438c00 atmos_4xdaily_fine_inst.tile4.nc
1094331a6b0aa718e6509521ae268159 atmos_4xdaily_fine_inst.tile5.nc
d4b2fe8b386577cb3d2eeb9d7cd727e2 atmos_4xdaily_fine_inst.tile6.nc
82157501c5b777a6e51603f36d381a8c RESTART/fv_core.res.nc
3776fd756dace0f597ec422043c7f118 RESTART/fv_core.res.tile1.nc
f9fdbac96cf7a0fb09c6fef4e2529cff RESTART/fv_core.res.tile2.nc
9d34f5adfd62b4e47e35d85bd5a2af24 RESTART/fv_core.res.tile3.nc
a6feac056ec48e4ca8289d4180d8d396 RESTART/fv_core.res.tile4.nc
6654dcf19e08d45aff075cdf09148cf5 RESTART/fv_core.res.tile5.nc
7fe463915eec05ad8d003ea8304a3269 RESTART/fv_core.res.tile6.nc
fbeeab6ab11e26787de05bafb7853ab1 RESTART/fv_srf_wnd.res.tile1.nc
91e20c755b0f9545e73db907b1282706 RESTART/fv_srf_wnd.res.tile2.nc
b01f7387d64a8e49c94199892361e6de RESTART/fv_srf_wnd.res.tile3.nc
61affb199928a3b9e7b0ca351709083d RESTART/fv_srf_wnd.res.tile4.nc
f62cee640bc26fa4d5e9bf70b1104304 RESTART/fv_srf_wnd.res.tile5.nc
a08a35fd458971b5a4f2f81b3eba529f RESTART/fv_srf_wnd.res.tile6.nc
173da4ef4a258e778c47dd31271a3b8e RESTART/fv_tracer.res.tile1.nc
ee308d968032d9f83bac94957f68ea9f RESTART/fv_tracer.res.tile2.nc
c53da594d7e006ad0ef132410cd1f19b RESTART/fv_tracer.res.tile3.nc
0079487895fb0a593b52d8e760aa0614 RESTART/fv_tracer.res.tile4.nc
63f49f4d21ced8ba0fc50337271414d3 RESTART/fv_tracer.res.tile5.nc
3792fbcadc42564cd134495cf1e87381 RESTART/fv_tracer.res.tile6.nc
009eee5d146a8dd492bfc6052ccad11e RESTART/phy_data.tile1.nc
ed094092b41c9853bf85d84d43d1f7fd RESTART/phy_data.tile2.nc
e7122fe73228aca73a13c89a3d53f149 RESTART/phy_data.tile3.nc
ecc9f494e54293e09d50981300be7c26 RESTART/phy_data.tile4.nc
f6ac59fc70a90e246c28db7ee9da4c6d RESTART/phy_data.tile5.nc
8b15f645ac7f3fd52bcee6180edd1522 RESTART/phy_data.tile6.nc
e05299c68f47918b78d8df63aa939e22 RESTART/sfc_data.tile1.nc
5315048f47ab00fddf8834258fd2f080 RESTART/sfc_data.tile2.nc
05daf9a231493c752d251c676478744b RESTART/sfc_data.tile3.nc
1193578f82de05926290fbbf11099912 RESTART/sfc_data.tile4.nc
9c1e823605a277322c4231a5cedec333 RESTART/sfc_data.tile5.nc
7065033ee348c8f9d0f877b0712fbac7 RESTART/sfc_data.tile6.nc
37 changes: 0 additions & 37 deletions tests/pytest/reference/circleci/baroclinic/md5.txt

This file was deleted.

Loading