Skip to content

Commit 61c6fe0

Browse files
Add generic scripts to aid in building the prognostic run environment (#2035)
* Generalize install script for ESMF * Generalze install script for FMS * Generalize install script for NCEPlibs * Tag base image as 1.0.1 * Add script to install the fortran model * Add script for installation of fv3net Python dependencies * Add script for installing the Python wrapper * Add script to install call_py_fort * Parametrize local packages for fv3net install script
1 parent 2465a08 commit 61c6fe0

13 files changed

+141
-98
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
PREFIX=$1
5+
6+
URL=https://github.com/nbren12/call_py_fort.git
7+
BRANCH=v0.2.0
8+
git clone $URL --branch=$BRANCH $PREFIX
9+
cd $PREFIX
10+
make
11+
make install
12+
ldconfig

.environment-scripts/install_esmf.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CLONE_PREFIX=$1
5+
INSTALL_PREFIX=$2
6+
ESMF_OS=$3
7+
ESMF_COMPILER=$4
8+
ESMF_SITE=$5
9+
NETCDF_INCLUDE=$6
10+
11+
export ESMF_DIR=$CLONE_PREFIX
12+
export ESMF_INSTALL_PREFIX=$INSTALL_PREFIX
13+
export ESMF_INSTALL_MODDIR=$ESMF_INSTALL_PREFIX/include
14+
export ESMF_INSTALL_HEADERDIR=$ESMF_INSTALL_PREFIX/include
15+
export ESMF_INSTALL_LIBDIR=$ESMF_INSTALL_PREFIX/lib
16+
export ESMF_INSTALL_BINDIR=$ESMF_INSTALL_PREFIX/bin
17+
export ESMF_NETCDF_INCLUDE=$NETCDF_INCLUDE
18+
export ESMF_NETCDF_LIBS="-lnetcdf -lnetcdff"
19+
export ESMF_BOPT=O3
20+
21+
# These flags set how the build is configured depending on the platform:
22+
# https://github.com/esmf-org/esmf/tree/develop/build_config
23+
export ESMF_OS=$ESMF_OS
24+
export ESMF_COMPILER=$ESMF_COMPILER
25+
export ESMF_SITE=$ESMF_SITE
26+
27+
# We may want to upgrade to ESMF_8_1_0 to make things easier on other platforms.
28+
git clone -b ESMF_8_0_0 --depth 1 https://github.com/esmf-org/esmf.git $ESMF_DIR
29+
cd $ESMF_DIR
30+
make lib -j24
31+
make install
32+
make installcheck

.environment-scripts/install_fms.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
INSTALL_PREFIX=$1
5+
6+
cd $INSTALL_PREFIX
7+
autoreconf -f --install
8+
./configure
9+
make -j8
10+
mv $INSTALL_PREFIX/*/*.o $INSTALL_PREFIX/*/*.h $INSTALL_PREFIX/*/*.mod $INSTALL_PREFIX/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
PREFIX=$1
5+
PLATFORM=$2
6+
INSTALL_PREFIX=$3
7+
8+
cd $PREFIX
9+
./configure $PLATFORM
10+
make -j 8
11+
PREFIX=$INSTALL_PREFIX make install
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
REQUIREMENTS_PATH=$1
5+
LOCAL_DEPENDENCIES=${@:2}
6+
7+
pip install --no-cache-dir -r $REQUIREMENTS_PATH
8+
for dependency in $LOCAL_DEPENDENCIES
9+
do
10+
pip install --no-cache-dir --no-dependencies -e $dependency
11+
done
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CLONE_PREFIX=$1
5+
INSTALL_PREFIX=$2
6+
PLATFORM=$3
7+
COMPILER=$4
8+
9+
URL=https://github.com/NCAR/NCEPlibs.git
10+
SHA=3da51e139d5cd731c9fc27f39d88cb4e1328212b
11+
12+
git clone $URL $CLONE_PREFIX
13+
cd $CLONE_PREFIX
14+
git checkout $SHA
15+
mkdir -p $INSTALL_PREFIX
16+
echo "y" | bash make_ncep_libs.sh -s $PLATFORM -c $COMPILER -d $INSTALL_PREFIX -o 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
FV3_DIR=$1
5+
6+
make -C $FV3_DIR wrapper_build
7+
pip install --no-dependencies $FV3_DIR/wrapper/dist/*.whl

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CACHE_TAG =latest
1111
BEAM_VERSION = 2.37.0
1212
UBUNTU_IMAGE = ubuntu@sha256:9101220a875cee98b016668342c489ff0674f247f6ca20dfc91b91c0f28581ae
1313
# prognostic base image is updated manually, not on every commit
14-
PROGNOSTIC_BASE_VERSION = 1.0.0
14+
PROGNOSTIC_BASE_VERSION = 1.0.1
1515
DOCKER_INTERACTIVE_ARGS = \
1616
--tty \
1717
--interactive \

docker/prognostic_run/Dockerfile

+26-40
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,39 @@ FROM ${BASE_IMAGE} as bld
44

55
# build/install the fortran model
66
COPY external/fv3gfs-fortran/ /tmp/fortran-build
7-
RUN cd /tmp/fortran-build/FV3 && \
8-
./configure gnu_docker && \
9-
sed -i "33i CALLPYFORT=Y" conf/configure.fv3 && \
10-
make -j 8 && \
11-
PREFIX=/usr/local make install
12-
13-
# Python Stuff Here
14-
#
15-
# Equivalent to passing --no-cache-dir to every pip install
16-
ENV PIP_NO_CACHE_DIR=off
17-
18-
# Install dependencies
19-
COPY docker/prognostic_run/requirements.txt /tmp/requirements.txt
20-
RUN pip install -r /tmp/requirements.txt
21-
22-
# compile and install the wrapper. Then import fv3gfs.wrapper as a minimal test
23-
# that it works.
24-
RUN make -C /tmp/fortran-build/FV3 wrapper_build &&\
25-
pip3 install --no-dependencies /tmp/fortran-build/FV3/wrapper/dist/*.whl && \
26-
python3 -c 'import fv3gfs.wrapper'
7+
COPY .environment-scripts/install_fv3gfs_fortran.sh .
8+
RUN CALLPYFORT=Y bash install_fv3gfs_fortran.sh /tmp/fortran-build/FV3 gnu_docker /usr/local
279

10+
# Install the Python dependencies
11+
COPY docker/prognostic_run/requirements.txt /fv3net/docker/prognostic_run/requirements.txt
2812
COPY external/vcm /fv3net/external/vcm
29-
RUN pip3 install --no-dependencies -e /fv3net/external/vcm
30-
3113
COPY external/artifacts /fv3net/external/artifacts
32-
RUN pip3 install --no-dependencies -e /fv3net/external/artifacts
33-
3414
COPY external/loaders /fv3net/external/loaders
35-
RUN pip3 install --no-dependencies -e /fv3net/external/loaders
36-
3715
COPY external/fv3fit /fv3net/external/fv3fit
38-
RUN pip3 install --no-dependencies -e /fv3net/external/fv3fit
39-
4016
COPY external/fv3kube /fv3net/external/fv3kube
41-
RUN pip3 install --no-dependencies -e /fv3net/external/fv3kube
42-
4317
COPY workflows/post_process_run /fv3net/workflows/post_process_run
44-
RUN pip3 install --no-dependencies -e /fv3net/workflows/post_process_run
18+
COPY workflows/prognostic_c48_run/ /fv3net/workflows/prognostic_c48_run
19+
COPY external/emulation /fv3net/external/emulation
20+
COPY external/radiation /fv3net/external/radiation
21+
22+
COPY .environment-scripts/install_fv3net_python_dependencies.sh .
23+
RUN bash install_fv3net_python_dependencies.sh \
24+
/fv3net/docker/prognostic_run/requirements.txt \
25+
/fv3net/external/vcm \
26+
/fv3net/external/artifacts \
27+
/fv3net/external/loaders \
28+
/fv3net/external/fv3fit \
29+
/fv3net/external/fv3kube \
30+
/fv3net/workflows/post_process_run \
31+
/fv3net/workflows/prognostic_c48_run \
32+
/fv3net/external/emulation \
33+
/fv3net/external/radiation
34+
35+
# compile and install the wrapper. Then import fv3gfs.wrapper as a minimal test
36+
# that it works.
37+
COPY .environment-scripts/install_python_wrapper.sh .
38+
RUN CALLPYFORT=Y bash install_python_wrapper.sh /tmp/fortran-build/FV3
39+
RUN python3 -c 'import fv3gfs.wrapper'
4540

4641
RUN echo "ulimit -s unlimited" >> /etc/bash.bashrc && \
4742
mkdir /outdir && \
@@ -52,12 +47,7 @@ RUN echo "ulimit -s unlimited" >> /etc/bash.bashrc && \
5247
ENV LC_ALL=C.UTF-8
5348
ENV LANG=C.UTF-8
5449

55-
COPY workflows/prognostic_c48_run/ /fv3net/workflows/prognostic_c48_run
56-
RUN pip install --no-dependencies -e /fv3net/workflows/prognostic_c48_run
57-
5850
# Override microphysics emulation
59-
COPY external/emulation /fv3net/external/emulation
60-
RUN pip install --no-dependencies -e /fv3net/external/emulation
6151
ENV VAR_META_PATH=/fv3net/external/emulation/microphysics_parameter_metadata.yaml
6252
ENV OUTPUT_FREQ_SEC=18000
6353

@@ -66,10 +56,6 @@ COPY projects/microphysics/scripts /fv3net/projects/microphysics/scripts
6656
RUN chmod +x /fv3net/projects/microphysics/scripts/*
6757
ENV PATH=/fv3net/projects/microphysics/scripts:${PATH}
6858

69-
# Add python radiation port
70-
COPY external/radiation /fv3net/external/radiation
71-
RUN pip install --no-dependencies -e /fv3net/external/radiation
72-
7359
ENV PYTHONPATH=/fv3net/workflows/prognostic_c48_run:/fv3net/external/fv3fit:/fv3net/external/emulation:/fv3net/external/vcm:/fv3net/external/artifacts:/fv3net/external/loaders:/fv3net/external/fv3kube:/fv3net/workflows/post_process_run:/fv3net/external/radiation:${PYTHONPATH}
7460
WORKDIR /fv3net/workflows/prognostic_c48_run
7561
CMD ["bash"]

docker/prognostic_run/base.Dockerfile

+15-9
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,39 @@ RUN apt-get update && \
4747
rsync \
4848
wget
4949

50-
COPY docker/prognostic_run/scripts/install_esmf.sh install_esmf.sh
51-
RUN bash install_esmf.sh /usr/local/esmf
50+
COPY .environment-scripts/install_esmf.sh .
51+
RUN bash install_esmf.sh /esmf /usr/local/esmf Linux gfortran default
5252

53-
COPY docker/prognostic_run/scripts/install_fms.sh install_fms.sh
53+
COPY .environment-scripts/install_fms.sh .
5454
COPY external/fv3gfs-fortran/FMS /FMS
55-
RUN bash install_fms.sh /FMS
55+
RUN CC=/usr/bin/mpicc \
56+
FC=/usr/bin/mpif90 \
57+
LDFLAGS='-L/usr/lib' \
58+
LOG_DRIVER_FLAGS='--comments' \
59+
CPPFLAGS='-I/usr/include -Duse_LARGEFILE -DMAXFIELDMETHODS_=500 -DGFS_PHYS' \
60+
FCFLAGS='-fcray-pointer -Waliasing -ffree-line-length-none -fno-range-check -fdefault-real-8 -fdefault-double-8 -fopenmp' \
61+
bash install_fms.sh /FMS
5662

57-
COPY docker/prognostic_run/scripts/install_nceplibs.sh .
58-
RUN bash install_nceplibs.sh /opt/NCEPlibs
63+
COPY .environment-scripts/install_nceplibs.sh .
64+
RUN bash install_nceplibs.sh /NCEPlibs /opt/NCEPlibs linux gnu
5965

6066

6167
ENV ESMF_DIR=/usr/local/esmf
6268
ENV CALLPY_DIR=/usr/local
6369
ENV FMS_DIR=/FMS
6470
ENV FV3GFS_FORTRAN_DIR=/external/fv3gfs-fortran
65-
ENV ESMF_INC="-I${ESMF_DIR}/include -I${ESMF_DIR}/mod/modO3/Linux.gfortran.64.mpiuni.default/"
71+
ENV ESMF_INC="-I${ESMF_DIR}/include"
6672

6773
ENV FMS_LIB=${FMS_DIR}/libFMS/.libs/
6874
ENV ESMF_LIB=${ESMF_DIR}/lib
6975
ENV CALLPYFORT_LIB=${CALLPY_DIR}/lib
7076
ENV CALLPYFORT_INCL=${CALLPY_DIR}/include
7177
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ESMF_LIB}:${FMS_LIB}:${CALLPYFORT_LIB}
7278

73-
RUN cd /opt && git clone https://github.com/nbren12/call_py_fort.git --branch=v0.2.0
7479
ENV CALLPY=/opt/call_py_fort \
7580
PYTHONPATH=${CALLPY}/src/:$PYTHONPATH
76-
RUN cd ${CALLPY} && make && make install && ldconfig
81+
COPY .environment-scripts/install_call_py_fort.sh .
82+
RUN bash install_call_py_fort.sh $CALLPY
7783

7884
# Install gcloud
7985
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates gnupg curl gettext && \

docker/prognostic_run/scripts/install_esmf.sh

-21
This file was deleted.

docker/prognostic_run/scripts/install_fms.sh

-18
This file was deleted.

docker/prognostic_run/scripts/install_nceplibs.sh

-9
This file was deleted.

0 commit comments

Comments
 (0)