Skip to content
Snippets Groups Projects
Commit f0c30feb authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

update WRF

parent d12499ec
Branches
No related tags found
No related merge requests found
...@@ -11,18 +11,30 @@ sandbox: ...@@ -11,18 +11,30 @@ sandbox:
fi fi
@[ -d ./sandbox.wrf.dev ] && echo Exists: WRF Sandbox || true @[ -d ./sandbox.wrf.dev ] && echo Exists: WRF Sandbox || true
.PHONY: wrf.dev # WRF development image for two stage builds
wrf.dev:
@if [ ! -f ./wrf.dev.sif ]; then\
echo Building the WRF dev;\
make -C ../.. alma8.base;\
ln -s ../../containers/alma8.base .;\
sudo singularity build wrf.dev.sif Singularity.dev;\
fi
@[ -f ./wrf.dev.sif ] && echo Exists: WRF dev || true
.PHONY: em_real # WRF Real container .PHONY: em_real # WRF Real container
em_real: sandbox em_real: wrf.dev
@if [ ! -f WRF-$(WRF_VERSION)-$@.sif ]; then\ @if [ ! -f WRF-$(WRF_VERSION)-$@.sif ]; then\
echo Building em_real with WRF sandbox;\ echo Building em_real with WRF dev;\
sed 's,WRF_BUILD_TARGET=em_real,WRF_BUILD_TARGET=em_real,g' Singularity.wrf > Singularity.tmp;\ sed 's,WRF_BUILD_TARGET=em_real,WRF_BUILD_TARGET=em_real,g' Singularity.wrf > Singularity.tmp;\
sudo singularity build WRF-$(WRF_VERSION)-$@.sif Singularity.tmp;\ sudo singularity build WRF-$(WRF_VERSION)-$@.sif Singularity.tmp;\
rm Singularity.tmp;\ rm Singularity.tmp;\
fi fi
@[ -f WRF-$(WRF_VERSION)-$@.sif ] && echo Exists: WRF-$(WRF_VERSION)-$@.sif || true @[ -f WRF-$(WRF_VERSION)-$@.sif ] && echo Exists: WRF-$(WRF_VERSION)-$@.sif || true
.PHONY: em_les # WRF LES container .PHONY: em_les # WRF LES container
em_les: em_les: wrf.dev
@echo Building em_real with WRF sandbox @echo Building em_real with WRF sandbox
# replace compile target in twostage build setup # replace compile target in twostage build setup
sed 's,WRF_BUILD_TARGET=em_real,WRF_BUILD_TARGET=em_les,g' Singularity.wrf > Singularity.tmp sed 's,WRF_BUILD_TARGET=em_real,WRF_BUILD_TARGET=em_les,g' Singularity.wrf > Singularity.tmp
......
Bootstrap: localimage Bootstrap: localimage
From: ../../containers/alma8.base.sif From: alma8.base.sif
%labels %labels
maintainer IT-IMGW <it.img-wien@univie.ac.at> maintainer IT-IMGW <it.img-wien@univie.ac.at>
baseimage AlmaLinux8 baseimage AlmaLinux8
%apprun downloadwrf
WRF_VERSION=4.4.1
if [ $# -ne 0 ]; then
WRF_VERSION=1
fi
echo "[WRF.dev] Downloading WRF $WRF_VERSION from github:"
curl -SL https://github.com/wrf-model/WRF/releases/download/v${WRF_VERSION}/v${WRF_VERSION}.tar.gz
%apprun downloadwps
WPS_VERSION=4.4
if [ $# -ne 0 ]; then
WPS_VERSION=1
fi
echo "[WRF.dev] Downloading WPS $WPS_VERSION from github:"
curl -SL https://github.com/wrf-model/WPS/archive/refs/tags/v${WPS_VERSION}.tar.gz
%post %post
# Every line will be a layer in the container # Every line will be a layer in the container
...@@ -52,7 +67,6 @@ yum update -y \ ...@@ -52,7 +67,6 @@ yum update -y \
&& rm -rf /usr/share/man \ && rm -rf /usr/share/man \
&& ln -s /usr/include/openmpi-x86_64/ /usr/lib64/openmpi/include && ln -s /usr/include/openmpi-x86_64/ /usr/lib64/openmpi/include
# command prompt name # command prompt name
CNAME=wrf.dev CNAME=wrf.dev
# does not work goes into /.singularity.d/env/91-environment.sh # does not work goes into /.singularity.d/env/91-environment.sh
......
Bootstrap: localimage
From: sandbox.wrf.dev
Stage: build
# Two Stage Build of WRF
# use the sandbox development image
# 1. Compile the target
# 2. Copy relevant exe to target WRF container
# Make sure the ldd / linking and inputs are ok
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%post
# Build a WRF release from the sandbox
WRF_BUILD_TARGET=em_real
LDFLAGS="-lm"
JASPERINC=/usr/include/jasper/
JASPERLIB=/usr/lib64/
NETCDF=/usr/lib64/openmpi/
# Build WRF with Option 34 and 1
cd /wrf/WRF \
&& ./configure <<< $'34\r1\r' \
&& sed -i -e '/^DM_CC/ s/$/ -DMPI2_SUPPORT/' ./configure.wrf \
&& sed -i '/BUILD_RRTMG_FAST/d' ./configure.wrf \
&& /bin/csh ./compile $WRF_BUILD_TARGET 2>&1 | tee compile_wrf_arw_opt34.1.log
# Build WPS with WRF
cd /wrf/WPS \
&& ./configure <<< $'1\r' \
&& sed -i -e 's/-L$(NETCDF)\/lib/-L$(NETCDF)\/lib -lnetcdff /' ./configure.wps \
&& /bin/csh ./compile 2>&1 | tee compile_wps.log
# Copy everything to a save directory
# This needs to be compied to the final Stage
mkdir -p /wrf/run /wrf/bin \
&& cp -fL /wrf/WRF/run/* /wrf/run \
&& rm /wrf/run/*.exe \
&& find /wrf -iname '*.exe' -exec cp -vfL {} /wrf/bin/ \; \
&& cp /wrf/WPS/namelist* /wrf/run
Bootstrap: localimage
From: sandbox.wrf.dev
Stage: final
%files from build
# Copy only executables from WRF to directory
/wrf/bin /wrf/bin
/wrf/run /wrf/run
# WPS
/wrf/WPS/link_grib.csh /wrf/bin
/wrf/WPS/ungrib/Variable_Tables /wrf/run
/wrf/WPS/geogrid/GEOGRID* /wrf/run/geogrid/
/wrf/WPS/geogrid/gribmap.txt /wrf/run/geogrid/
/wrf/WPS/metgrid/METGRID* /wrf/run/metgrid/
/wrf/WPS/metgrid/gribmap.txt /wrf/run/metgrid/
# Log files
/wrf/WRF/compile_wrf_arw_opt34.1.log /wrf
/wrf/WPS/compile_wps.log /wrf
%files
./scripts/runscript /.singularity.d/runscript
./scripts/run-help /.singularity.d/runscript.help
%post
# compress
gzip -f /wrf/*.log
# remove src tree (is insidie sandbox)
rm -rf /wrf/WRF /wrf/WPS
# Strip the binaries to reduce the size of the image
find -L /wrf/* -type f -exec readlink -f '{}' \; | \
xargs file -i | \
grep 'charset=binary' | \
grep 'x-executable\|x-archive\|x-sharedlib' | \
awk -F: '{print $1}' | xargs strip -s
# command prompt name
WRF_BUILD_TARGET=em_real
CNAME=alma8.wrf.$WRF_BUILD_TARGET
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
%environment
export PATH=/wrf/bin:$PATH
export WRF_BUILD_TARGET=em_real
Bootstrap: localimage Bootstrap: localimage
From: sandbox.wrf.dev From: wrf.dev
Stage: build Stage: build
# Two Stage Build of WRF # Two Stage Build of WRF
...@@ -11,6 +11,10 @@ Stage: build ...@@ -11,6 +11,10 @@ Stage: build
%labels %labels
maintainer IT-IMGW <it.img-wien@univie.ac.at> maintainer IT-IMGW <it.img-wien@univie.ac.at>
%files
WRF*.tar.gz /wrf
WPS*.tar.gz /wrf
%post %post
# Build a WRF release from the sandbox # Build a WRF release from the sandbox
WRF_BUILD_TARGET=em_real WRF_BUILD_TARGET=em_real
...@@ -19,6 +23,10 @@ JASPERINC=/usr/include/jasper/ ...@@ -19,6 +23,10 @@ JASPERINC=/usr/include/jasper/
JASPERLIB=/usr/lib64/ JASPERLIB=/usr/lib64/
NETCDF=/usr/lib64/openmpi/ NETCDF=/usr/lib64/openmpi/
mkdir -vp /wrf/WRF /wrf/WPS
cat /wrf/WRF*.tar.gz | tar --no-same-owner --strip-components=1 -zxC /wrf/WRF
cat /wrf/WPS*.tar.gz | tar --no-same-owner --strip-components=1 -zxC /wrf/WPS
# Build WRF with Option 34 and 1 # Build WRF with Option 34 and 1
cd /wrf/WRF \ cd /wrf/WRF \
&& ./configure <<< $'34\r1\r' \ && ./configure <<< $'34\r1\r' \
...@@ -41,7 +49,7 @@ mkdir -p /wrf/run /wrf/bin \ ...@@ -41,7 +49,7 @@ mkdir -p /wrf/run /wrf/bin \
&& cp /wrf/WPS/namelist* /wrf/run && cp /wrf/WPS/namelist* /wrf/run
Bootstrap: localimage Bootstrap: localimage
From: sandbox.wrf.dev From: wrf.dev
Stage: final Stage: final
%files from build %files from build
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment