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

Feature/40 build wrf container #72

Merged
merged 16 commits into from
Dec 6, 2024
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
libs
*~
.vs
/.DS_Store
107 changes: 107 additions & 0 deletions docker/iwrf/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Cornell uses ubuntu 22.04
FROM ubuntu:22.04 as wrfbuild

# Update the OS
RUN apt -y update
RUN apt -y upgrade

# Install compilers
RUN apt -y install cmake pkg-config build-essential wget libcurl4-openssl-dev m4
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor > /usr/share/keyrings/oneapi-archive-keyring.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list
RUN apt -y update
RUN apt -y install intel-oneapi-compiler-fortran-2023.1.0 intel-oneapi-dpcpp-cpp-2023.1.0 intel-oneapi-mpi-2021.9.0 intel-oneapi-mpi-devel-2021.9.0
RUN apt -y --fix-broken install
RUN apt -y update

# Install other required packages
RUN apt -y install libexpat1 libexpat1-dev expat git csh file

# Install packages used for debugging
RUN apt -y install vim

# Add system user
RUN useradd -u 5000 wrfuser

# Configure bash
RUN echo 'source /etc/bash.bashrc' >> /etc/bashrc
RUN echo 'export MPI="/opt/intel/oneapi/mpi/latest"' >> /etc/bashrc
RUN echo 'export OPENMPI="${MPI}"' >> /etc/bashrc
RUN echo 'export INTEL="/opt/intel/oneapi/compiler/latest/linux"' >> /etc/bashrc
RUN echo 'export PATH="${INTEL}/bin/intel64:${MPI}/bin:${PATH}"' >> /etc/bashrc
RUN echo 'export SCC="icx"' >> /etc/bashrc
RUN echo 'export SFC="ifx"' >> /etc/bashrc
RUN echo 'export I_MPI_CC="icx"' >> /etc/bashrc
RUN echo 'export I_MPI_CXX="icpx"' >> /etc/bashrc
RUN echo 'export I_MPI_FC="ifx"' >> /etc/bashrc
RUN echo 'export I_MPI_F90="ifx"' >> /etc/bashrc
RUN echo 'export FC="mpifc"' >> /etc/bashrc
RUN echo 'export F90="mpifc"' >> /etc/bashrc
RUN echo 'export F77="mpifc"' >> /etc/bashrc
RUN echo 'export CC="mpicc"' >> /etc/bashrc
RUN echo 'export CXX="mpicxx"' >> /etc/bashrc
RUN echo 'export CPP="${CC} -E"' >> /etc/bashrc
RUN echo 'export CC_FOR_BUILD="${CC}"' >> /etc/bashrc
RUN echo 'export CPP_FOR_BUILD="${CPP}"' >> /etc/bashrc
RUN echo 'export CXXCPP="${CXX} -E"' >> /etc/bashrc
RUN echo 'export ABI="64"' >> /etc/bashrc
RUN echo 'export FCFLAGS="-I${MPI}/include"' >> /etc/bashrc
RUN echo 'export CFLAGS="-I${MPI}/include"' >> /etc/bashrc
RUN echo 'export LDFLAGS="-L${MPI}/lib -L${MPI}/lib/release"' >> /etc/bashrc
RUN echo 'export LD_LIBRARY_PATH="${MPI}/lib/release:${MPI}/lib"' >> /etc/bashrc
RUN echo 'source /opt/intel/oneapi/setvars.sh --force > /dev/null' >> /etc/bashrc
RUN echo 'export PATH="/opt/intel/oneapi/mpi/latest/bin:${PATH}"' >> /etc/bashrc
RUN echo 'export WRFUSER="wrfuser"' >> /etc/bashrc
# TODO: This is not taking effect for the stack, we had to manually run: 'ulimit -s unlimited'
RUN echo '* hard stack unlimited' >> /etc/security/limits.conf
RUN echo '* soft stack unlimited' >> /etc/security/limits.conf

# Download source
RUN mkdir -p /opt/src
WORKDIR /opt/src
RUN wget https://www.wrfcloud.com/libs/cmake-3.25.0-rc3.tar.gz
RUN wget https://www.wrfcloud.com/libs/eccodes-2.27.0.tar.gz
RUN wget https://www.wrfcloud.com/libs/g2clib-1.6.0-patch.tar.gz
RUN wget https://www.wrfcloud.com/libs/jasper-1.900.1.tar.gz
RUN wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.10/src/hdf5-1.10.10.tar.gz
RUN wget https://www.wrfcloud.com/libs/libaec-v1.0.6.tar.gz
RUN wget https://www.wrfcloud.com/libs/libpng-1.2.50.tar.gz
RUN wget https://www.wrfcloud.com/libs/ncview-2.1.7.tar.gz
RUN wget https://www.wrfcloud.com/libs/netcdf-4.7.3.tar.gz
RUN wget https://www.wrfcloud.com/libs/netcdf-cxx-4.3.1.tar.gz
RUN wget https://www.wrfcloud.com/libs/netcdf-fortran-4.5.2.tar.gz
RUN wget https://www.wrfcloud.com/libs/szip-2.1.1.tar.gz
RUN wget https://www.wrfcloud.com/libs/zlib-1.2.11.tar.gz
RUN wget https://downloads.unidata.ucar.edu/udunits/2.2.28/udunits-2.2.28.tar.gz

#COPY WPS.patch /tmp/WPS.patch
COPY build_wrf.sh /tmp/build_wrf.sh
RUN bash /tmp/build_wrf.sh


FROM ubuntu:22.04

# Update the OS
RUN apt -y update
RUN apt -y upgrade

COPY --from=wrfbuild /home/wrfuser /home/wrfuser
COPY --from=wrfbuild /opt/hdf5 /opt/hdf5
COPY --from=wrfbuild /opt/jasper /opt/jasper
COPY --from=wrfbuild /opt/libpng /opt/libpng
COPY --from=wrfbuild /opt/netcdf /opt/netcdf
COPY --from=wrfbuild /opt/szip /opt/szip
COPY --from=wrfbuild /opt/udunits /opt/udunits
COPY --from=wrfbuild /opt/zlib /opt/zlib
COPY --from=wrfbuild /etc/bashrc /etc/bashrc

# Install required runtime packages
# Note: To get a list of Intel OneAPI runtime packages, run the following:
# apt-cache pkgnames intel | grep intel-oneapi-runtime
RUN apt -y install cmake pkg-config build-essential wget libcurl4-openssl-dev m4 csh
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor > /usr/share/keyrings/oneapi-archive-keyring.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" > /etc/apt/sources.list.d/oneAPI.list
RUN apt -y update
RUN apt -y install intel-oneapi-runtime-mpi-2021 intel-oneapi-common-vars intel-oneapi-compiler-shared-runtime-2023.1.0 intel-oneapi-compiler-fortran-runtime-2023.1.0

WORKDIR /home/wrfuser
136 changes: 136 additions & 0 deletions docker/iwrf/WPS.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
--- WPS/ungrib/src/cio.c 2024-03-22 21:46:05.026504170 +0000
+++ WPS-patch/ungrib/src/cio.c 2024-03-22 22:03:15.537543342 +0000
@@ -48,8 +48,6 @@
#endif

/* ****************************************************************** */
-
-c_open(unit, nunit, name, mode, err, oflag)
/*
* unit = Fortran unit number
* nunit = UNIX file descriptor associated with 'unit'
@@ -64,12 +62,15 @@
= 1 : file name and unit number printed (and errors)
= -1 : no print at all (not even errors)
*/
- int *unit;
- int *nunit;
- int *mode;
- int *err;
- int *oflag;
- char name[FORT_FILE_LEN];
+int
+c_open(
+ int *unit,
+ int *nunit,
+ char name[FORT_FILE_LEN],
+ int *mode,
+ int *err,
+ int *oflag
+ )
{
int fd, i;
char fname[FORT_FILE_LEN];
@@ -114,8 +115,6 @@
}

/* ****************************************************************** */
-bn_seek(fd, bread, mode, iprint)
-
/* Move the read/write file pointer
fd : Unix file descriptor.
bread : Number of bytes to move the pointer.
@@ -128,9 +127,13 @@
Location 0 [bn_seek(fd,0,-1,0)] puts us just before the first byte,
so the next bn_read will get byte 1.
*/
-
- int *fd, *bread, *mode, *iprint;
-
+int
+bn_seek(
+ int *fd,
+ int *bread,
+ int *mode,
+ int *iprint
+ )
{
off_t i, offset;
int how_to_space;
@@ -151,8 +154,6 @@
}

/* ****************************************************************** */
-
-bn_read(fd, buf, nbuf, bread, ios, idiag)
/*
* fd = UNIX file descriptor number (NOT a Fortran unit)
* buf = area into which to read
@@ -163,8 +164,15 @@
2 = Error in reading
* idiag : if non-zero, error and EOF messages will be printed
*/
-
- int *fd, *nbuf, buf[], *bread, *ios, *idiag;
+int
+bn_read(
+ int *fd,
+ int buf[],
+ int *nbuf,
+ int *bread,
+ int *ios,
+ int *idiag
+ )
{
int bytesread;

@@ -197,17 +205,21 @@
}

/* ****************************************************************** */
-
-bnwrit_(fd, buf, nbuf, bwritten, err, idiag)
- int *fd, *nbuf, buf[], *bwritten, *err, *idiag;
-
/*
* fd = UNIX file descriptor number (NOT a Fortran unit) buf = area from
* which to write nbuf = number of bytes to write to fd bwritten = number
* actually written err = UNIX error number returned to FORTRAN idiag : if
* non-zero, error and EOF messages will be printed
*/
-
+int
+bnwrit_(
+ int *fd,
+ int buf[],
+ int *nbuf,
+ int *bwritten,
+ int *err,
+ int *idiag
+ )
{
int byteswritten;

@@ -231,8 +243,6 @@
}

/* ****************************************************************** */
-
-c_close(nunit, iprint, err)
/*
Close a C (UNIX?) file descriptor:
nunit : (INPUT) : The C (UNIX?) file descriptor to close.
@@ -241,7 +251,12 @@
err : (OUTPUT) : Error flag ( err = 0 : Successful close)
( err = 1 : Error on close)
*/
- int *nunit, *iprint, *err;
+int
+c_close(
+ int *nunit,
+ int *iprint,
+ int *err
+ )
{
extern int errno; /* I/O error return */
int istat;
3 changes: 3 additions & 0 deletions docker/iwrf/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

docker build --no-cache -f Dockerfile . 2>&1 | tee build.log
Loading
Loading