Skip to content

Commit 2b163c3

Browse files
committed
full workflow include WPS
1 parent 9d99d45 commit 2b163c3

File tree

1 file changed

+139
-43
lines changed
  • docs/build-install/applications

1 file changed

+139
-43
lines changed

docs/build-install/applications/wrf.md

Lines changed: 139 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -88,78 +88,96 @@ module load wrf
8888

8989
## CRYOWRF
9090

91-
9291
[CRYOWRF](https://gitlabext.wsl.ch/atmospheric-models/CRYOWRF) is a coupled atmosphere-snow cover model with WRF acting as the atmospheric core and SNOWPACK acting as snow cover model.
9392

94-
Building CRYOWRF is a two step process:
93+
Building CRYOWRF is a three step process:
9594

95+
1. install the dependencies like [`parallel-netcdf`](https://packages.spack.io/package.html?name=parallel-netcdf)
9696
1. build the SNOWPACK extension
97-
2. Build the bundled WRF
97+
1. Build the bundled WRF
9898

9999
!!! note
100100
This workflow was developed in July 2025 using the most recent commit `8f83858f` of [CRYOWRF](https://gitlabext.wsl.ch/atmospheric-models/CRYOWRF) (commited in August 2023).
101101

102-
The code does not appear to be regularly updated, so we expect that it will slowly become more difficult to build as time passes.
102+
It isn't very easy to install, and we have tried to streamline the process as much as possible, so take your time and follow the instructions closely.
103103

104104
!!! warning "Eiger only"
105105
This guide is for building on [Eiger][ref-cluster-eiger], which is an x86-based system.
106106

107107
Building on the Grace-Hopper clusters like [Daint][ref-cluster-daint] is
108108

109-
We use [`prgenv-gnu/24.11:v2`][ref-uenv-prgenv-gnu] [uenv][ref-uenv], which can be downloaded:
109+
We use [`prgenv-gnu/24.11:v2`][ref-uenv-prgenv-gnu] [uenv][ref-uenv].
110+
111+
### Step 1: install required packages
110112

113+
The first step is to create an empty directory where everything will be installed.
114+
Here, we create it in your project's [Store][ref-storage-store] path, where the package can be accessed by all users in your project.
111115
```bash
112-
uenv image pull prgenv-gnu/24.11:v2
116+
export WRFROOT=$STORE/wrf
117+
mkdir $WRFROOT
118+
cd $WRFROOT
113119
```
114120

115-
### Step 0: install required packages
121+
The following dependencies that are not provided by `prgenv-gnu` are required:
116122

117-
```
118-
mkdir $STORE/wrf
119-
cd $STORE/wrf
120-
export WRFPATH=$STORE/wrf
121-
```
123+
* `parallel-netcdf`: used by WRF.
124+
* `jasper~shared`: used by WPS (`~shared` will build static libraries, required by WPS).
125+
* `zlib-ng` and `libpng`: used by WPS.
122126

123-
```
127+
Then follow the steups in the [uenv-spack][ref-building-uenv-spack] guide to install `uenv-spack`, which will be used to install the dependencies
128+
129+
```bash
130+
# start the uenv with the spack view enabled
124131
uenv start prgenv-gnu/24.11:v2 --view=spack
132+
133+
# download and install uenv-spack
134+
cd $WRFROOT
125135
git clone https://github.com/eth-cscs/uenv-spack.git
126136
(cd uenv-spack && ./bootstrap)
127-
./uenv-spack/uenv-spack $PWD/dependencies --uarch=zen2 --specs=parallel-netcdf,jasper,libpng,zlib-ng
137+
```
128138

129-
cd dependencies
139+
Now we configure and build the environment (the final "build" phase will take a while - 5-10 minutes typically)
140+
```bash
141+
export WRFDEPS=$WRFROOT/dependencies
142+
$WRFROOT/uenv-spack/uenv-spack $WRFDEPS --uarch=zen2 --specs='parallel-netcdf,jasper~shared,libpng,zlib-ng'
143+
cd $WRFDEPS
130144
./build
131145
```
132146

133-
This step is performed once, and will install the software in `$WRFPATH/dependencies/view`
147+
Now the dependencies are installed, finish the uenv spack session:
134148

135-
Finish the uenv session:
136-
```
149+
```bash
137150
exit
138151
```
139152

140-
### Step 1: build SNOWPACK
153+
!!! warning
154+
This step is performed once, and will install the software in `$WRFDEPS`, where they can be used to build and run WRF.
141155

156+
### Step 2: build SNOWPACK
157+
158+
Use the `default` view of `prgenv-gnu` to build SNOWPACK, WRF and WPS:
142159

143160
```
161+
export WRFROOT=$STORE/wrf
144162
uenv start prgenv-gnu/24.11:v2 --view=default
145163
```
146164

147-
Clone the software
148-
149-
```bash
150-
cd $WRFPATH
151-
git clone https://gitlabext.wsl.ch/atmospheric-models/CRYOWRF.git
152-
cd CRYOWRF
153-
```
154-
155165
!!! note
156166
You don't need to load any modules: the `default` view will add everything to your environment.
157167

168+
First download the CRYOWRF software:
158169

170+
```bash
171+
git clone https://gitlabext.wsl.ch/atmospheric-models/CRYOWRF.git $WRFROOT/CRYOWRF
172+
cd $WRFROOT/CRYOWRF
159173
```
174+
175+
Set the following environment variables:
176+
177+
```bash
160178
export NETCDF=/user-environment/env/default
161179
export HDF5=/user-environment/env/default
162-
export PNETCDF=$WRFPATH/dependencies/view
180+
export PNETCDF=$WRFDEPS/view
163181
export WRF_EM_CORE=1
164182
export WRF_NMM_CORE=0
165183
export WRF_DA_CORE=0
@@ -171,31 +189,28 @@ export NETCDF4=1
171189
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
172190
export WRFIO_NCD_NO_LARGE_FILE_SUPPORT=0
173191

174-
export JASPERLIB=$WRFPATH/dependencies/view/lib64
175-
export JASPERINC=$WRFPATH/dependencies/view/include
192+
export JASPERLIB=$WRFDEPS/view/lib64
193+
export JASPERINC=$WRFDEPS/view/include
176194

177195
export CC=mpicc
178196
export FC=mpifort
179197
export CXX=mpic++
180-
181-
ulimit -s unlimited
182-
ulimit -c unlimited
183198
```
184199

185-
clean and compile
200+
Then compile SNOWPACK:
201+
186202
```
187203
./clean.sh
188204
./compiler_snow_libs.sh
189205
```
190206

207+
### Step 3: build WRF
191208

192-
### Step 2: build WRF
193-
194-
The CRYOWRF repository includes a copy of WRF v4.2.1, that has been modified to integrate the SNOWPACK extension build in step 1.
209+
The CRYOWRF repository includes a copy of WRF v4.2.1, that has been modified to integrate the SNOWPACK extension build in the previous step.
195210

196-
```
197-
export SNOWLIBS=$WRFPATH/CRYOWRF/snpack_for_wrf
198-
cd WRF
211+
```bash
212+
export SNOWLIBS=$WRFROOT/CRYOWRF/snpack_for_wrf
213+
cd $WRFROOT/CRYOWRF/WRF
199214
./clean -a
200215
# [choose option 35][nesting: choose option 1] when prompted by configure
201216
./configure
@@ -204,8 +219,9 @@ cd WRF
204219
!!! info "Set `SNOWLIBS`"
205220
The `SNOWLIBS` environment variable needs to be set so that WRF can find the extension we compiled earlier.
206221

207-
Make sure that the following lines are set in `configure.wrf`:
208-
```
222+
Open the configure.wrf file that was generated by calling `./configure`, and update the following lines:
223+
224+
```bash
209225
SFC = gfortran
210226
SCC = gcc
211227
CCOMP = gcc
@@ -216,8 +232,88 @@ FCBASEOPTS = $(FCBASEOPTS_NO_G) $(FCDEBUG) -fallow-argument-mismatch -fa
216232
NETCDFPATH = /user-environment/env/default
217233
```
218234

219-
Now compile WRF :fingers-crossed:
235+
And apply the following "patch":
236+
```bash
237+
sed -i 's|hdf5hl|hdf5_hl|g' configure.wrf
238+
```
239+
240+
Now compile WRF, which will take a while:
220241

221242
```
222243
./compile em_real -j 64 &> log_compile
223244
```
245+
246+
The compilation output is captured in `log_compile`.
247+
On success, the log should have the message `Executables successfully built`:
248+
249+
```console
250+
$ tail -n14 log_compile
251+
252+
==========================================================================
253+
build started: Thu 10 Jul 2025 04:54:53 PM CEST
254+
build completed: Thu 10 Jul 2025 05:17:41 PM CEST
255+
256+
---> Executables successfully built <---
257+
258+
-rwxr-xr-x 1 bcumming csstaff 121952104 Jul 10 17:16 main/ndown.exe
259+
-rwxr-xr-x 1 bcumming csstaff 121728120 Jul 10 17:17 main/real.exe
260+
-rwxr-xr-x 1 bcumming csstaff 120519144 Jul 10 17:17 main/tc.exe
261+
-rwxr-xr-x 1 bcumming csstaff 141159472 Jul 10 17:14 main/wrf.exe
262+
263+
==========================================================================
264+
```
265+
266+
### Step 4: build WPS
267+
268+
Using the same environment configured
269+
270+
```
271+
cd $WRFROOT/CRYOWRF/WPS-4.2
272+
# choose option 2
273+
./configure
274+
```
275+
276+
Update `configure.wps` as follows:
277+
```
278+
SFC = gfortran
279+
SCC = gcc
280+
DM_FC = mpif90
281+
DM_CC = mpicc
282+
FC = gfortran
283+
CC = gcc
284+
LD = $(FC)
285+
FFLAGS = -ffree-form -O -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fallow-invalid-boz
286+
F77FLAGS = -ffixed-form -O -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fallow-invalid-boz
287+
```
288+
289+
Note the arguments `-fallow-argument-mismatch -fallow-invalid-boz` added to `FFLAGS` and `F77FLAGS`.
290+
291+
Then compile:
292+
```
293+
./compile &> log_compile
294+
```
295+
296+
The compilation output is captured in `log_compile`.
297+
On success, the log should have the message `Executables successfully built`:
298+
299+
```console
300+
$ tail -n14 log_compile
301+
```
302+
303+
### Running CRYOWRF
304+
305+
Add the following to your SBATCH job script:
306+
```bash
307+
#SBATCH --uenv=prgenv-gnu/24.11:v2
308+
#SBATCH --view=default
309+
310+
# set LD_LIBRARY_PATH to find the dependencies installed in step 1
311+
export WRFROOT=$STORE/wrf
312+
export WRFDEPS=$WRFROOT/dependencies
313+
export LD_LIBRARY_PATH=$WRFDEPS/view/lib:$WRFDEPS/view/lib64:$LD_LIBRARY_PATH
314+
315+
# set other environment variables
316+
317+
# then run wrf.exe
318+
wrf.exe
319+
```

0 commit comments

Comments
 (0)