Skip to content

Commit 013e87c

Browse files
committed
add summary scripts to wrf docs
1 parent 01e97c2 commit 013e87c

File tree

1 file changed

+198
-11
lines changed
  • docs/build-install/applications

1 file changed

+198
-11
lines changed

docs/build-install/applications/wrf.md

Lines changed: 198 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ git clone https://github.com/eth-cscs/uenv-spack.git
2323
(cd uenv-spack && ./bootstrap)
2424
```
2525

26+
!!! warning
27+
Run the step of downloading and running the bootstrap script for `uenv-spack` _before_ starting a uenv.
28+
2629
The [`prgenv-gnu`][ref-uenv-prgenv-gnu] uenv is suitable for building WRF.
2730
```
2831
uenv start prgenv-gnu/24.11:v2 --view=spack
@@ -110,11 +113,45 @@ We use [`prgenv-gnu/24.11:v2`][ref-uenv-prgenv-gnu] [uenv][ref-uenv].
110113

111114
### Step 1: install required packages
112115

116+
??? example "Full script"
117+
Here is the full script for the steps described in this step.
118+
119+
```bash
120+
# the root directory under which all dependencies and WRF/CRYOWRF will be installed
121+
export WRFROOT=$STORE/wrf
122+
# the directory where we will install the dependencies of WRF/CRYOWRF/WPS
123+
export WRFDEPS=$WRFROOT/dependencies
124+
125+
# assume that we are crating WRFROOT for the first time
126+
mkdir $WRFROOT
127+
128+
# download and install uenv-spack
129+
git clone https://github.com/eth-cscs/uenv-spack.git $WRFROOT/uenv-spack
130+
(cd $WRFROOT/uenv-spack && ./bootstrap)
131+
132+
# start the uenv with the spack view enabled
133+
# warning: bootstrap the uenv-spack tool _before_ starting the uenv
134+
uenv start prgenv-gnu/24.11:v2 --view=spack
135+
136+
# configure the environment and build it
137+
$WRFROOT/uenv-spack/uenv-spack $WRFDEPS --uarch=zen2 --specs='parallel-netcdf,jasper~shared,libpng,zlib-ng'
138+
cd $WRFDEPS
139+
./build
140+
141+
# finish the session
142+
exit
143+
```
144+
113145
The first step is to create an empty directory where everything will be installed.
114146
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.
115147
```bash
148+
# the root directory under which all dependencies and WRF/CRYOWRF will be installed
116149
export WRFROOT=$STORE/wrf
150+
# the directory where we will install the dependencies of WRF/CRYOWRF/WPS
151+
export WRFDEPS=$WRFROOT/dependencies
152+
# assume that we are crating WRFROOT for the first time
117153
mkdir $WRFROOT
154+
118155
cd $WRFROOT
119156
```
120157

@@ -127,18 +164,20 @@ The following dependencies that are not provided by `prgenv-gnu` are required:
127164
Then follow the steps in the [uenv-spack][ref-building-uenv-spack] guide to install `uenv-spack`, which will be used to install the dependencies
128165

129166
```bash
130-
# start the uenv with the spack view enabled
131-
uenv start prgenv-gnu/24.11:v2 --view=spack
132-
133167
# download and install uenv-spack
134-
cd $WRFROOT
135-
git clone https://github.com/eth-cscs/uenv-spack.git
136-
(cd uenv-spack && ./bootstrap)
168+
git clone https://github.com/eth-cscs/uenv-spack.git $WRFROOT/uenv-spack
169+
(cd $WRFROOT/uenv-spack && ./bootstrap)
137170
```
138171

139-
Now we configure and build the environment (the final "build" phase will take a while - 5-10 minutes typically)
172+
!!! warning
173+
Run the step of downloading and running the bootstrap script for `uenv-spack` _before_ starting a uenv.
174+
175+
Now we configure and build the environment, note that the final "build" phase will take a around 5-10 minutes.
176+
140177
```bash
141-
export WRFDEPS=$WRFROOT/dependencies
178+
# start the uenv with the spack view enabled
179+
uenv start prgenv-gnu/24.11:v2 --view=spack
180+
142181
$WRFROOT/uenv-spack/uenv-spack $WRFDEPS --uarch=zen2 --specs='parallel-netcdf,jasper~shared,libpng,zlib-ng'
143182
cd $WRFDEPS
144183
./build
@@ -150,15 +189,57 @@ Now the dependencies are installed, finish the uenv spack session:
150189
exit
151190
```
152191

153-
!!! warning
192+
!!! note
154193
This step is performed once, and will install the software in `$WRFDEPS`, where they can be used to build and run WRF.
155194

156195
### Step 2: build SNOWPACK
157196

197+
??? example "Full script"
198+
Here is the full script, that is described in detail in this step.
199+
200+
```bash
201+
uenv start --view-default prgenv-gnu/24.11:v2
202+
203+
# set the paths to match those used in Step 1
204+
export WRFROOT=$STORE/wrf
205+
export WRFDEPS=$WRFROOT/dependencies
206+
207+
git clone https://gitlabext.wsl.ch/atmospheric-models/CRYOWRF.git $WRFROOT/CRYOWRF
208+
cd $WRFROOT/CRYOWRF
209+
210+
export NETCDF=/user-environment/env/default
211+
export HDF5=/user-environment/env/default
212+
export PNETCDF=$WRFDEPS/view
213+
214+
export WRF_EM_CORE=1
215+
export WRF_NMM_CORE=0
216+
export WRF_DA_CORE=0
217+
218+
export WRF_CHEM=0
219+
export WRF_KPP=0
220+
221+
export NETCDF4=1
222+
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
223+
export WRFIO_NCD_NO_LARGE_FILE_SUPPORT=0
224+
225+
export CC=mpicc
226+
export FC=mpifort
227+
export CXX=mpic++
228+
229+
./clean.sh
230+
./compiler_snow_libs.sh
231+
232+
# finish the session
233+
exit
234+
```
235+
158236
Use the `default` view of `prgenv-gnu` to build SNOWPACK, WRF and WPS:
159237

160238
```
239+
# set the paths to match those used in Step 1
161240
export WRFROOT=$STORE/wrf
241+
export WRFDEPS=$WRFROOT/dependencies
242+
162243
uenv start prgenv-gnu/24.11:v2 --view=default
163244
```
164245

@@ -178,8 +259,6 @@ Set the following environment variables:
178259
export NETCDF=/user-environment/env/default
179260
export HDF5=/user-environment/env/default
180261
export PNETCDF=$WRFDEPS/view
181-
export JASPERLIB=$WRFDEPS/view/lib64
182-
export JASPERINC=$WRFDEPS/view/include
183262

184263
export WRF_EM_CORE=1
185264
export WRF_NMM_CORE=0
@@ -204,8 +283,64 @@ Then compile SNOWPACK:
204283
./compiler_snow_libs.sh
205284
```
206285

286+
207287
### Step 3: build WRF
208288

289+
??? example "Full script"
290+
Here is the full script, that is described in detail in this step.
291+
292+
```bash
293+
uenv start --view-default prgenv-gnu/24.11:v2
294+
295+
# set the paths to match those used in Step 1
296+
export WRFROOT=$STORE/wrf
297+
export WRFDEPS=$WRFROOT/dependencies
298+
299+
# required for the CRYOWRF build to find SNOWPACK built in step 1
300+
export SNOWLIBS=$WRFROOT/CRYOWRF/snpack_for_wrf
301+
302+
# set variables used by the WRF build tool
303+
export NETCDF=/user-environment/env/default
304+
export HDF5=/user-environment/env/default
305+
export PNETCDF=$WRFDEPS/view
306+
307+
export WRF_EM_CORE=1
308+
export WRF_NMM_CORE=0
309+
export WRF_DA_CORE=0
310+
311+
export WRF_CHEM=0
312+
export WRF_KPP=0
313+
314+
export NETCDF4=1
315+
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
316+
export WRFIO_NCD_NO_LARGE_FILE_SUPPORT=0
317+
318+
export CC=mpicc
319+
export FC=mpifort
320+
export CXX=mpic++
321+
322+
git clone https://gitlabext.wsl.ch/atmospheric-models/CRYOWRF.git $WRFROOT/CRYOWRF
323+
cd $WRFROOT/CRYOWRF/WRF
324+
325+
./clean -a
326+
# [choose option 34][nesting: choose option 1] when prompted by configure
327+
./configure
328+
329+
# edit configure.wrf
330+
vim configure.wrf
331+
# SFC = gfortran
332+
# SCC = gcc
333+
# CCOMP = gcc
334+
# DM_FC = mpif90
335+
# DM_CC = mpicc
336+
# FC = mpif90
337+
# FCBASEOPTS = $(FCBASEOPTS_NO_G) $(FCDEBUG) -fallow-argument-mismatch -fallow-invalid-boz -g
338+
# NETCDFPATH = /user-environment/env/default
339+
340+
sed -i 's|hdf5hl|hdf5_hl|g' configure.wrf
341+
./compile em_real -j 64 &> log_compile
342+
```
343+
209344
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.
210345

211346
```bash
@@ -265,6 +400,46 @@ build completed: Thu 10 Jul 2025 05:17:41 PM CEST
265400

266401
### Step 4: build WPS
267402

403+
??? example "Full script"
404+
Here is the full script, that is described in detail in this step.
405+
406+
```bash
407+
uenv start --view-default prgenv-gnu/24.11:v2
408+
409+
# set the paths to match those used in Step 1
410+
export WRFROOT=$STORE/wrf
411+
export WRFDEPS=$WRFROOT/dependencies
412+
413+
# set variables used by the WRF build tool
414+
export NETCDF=/user-environment/env/default
415+
export HDF5=/user-environment/env/default
416+
export PNETCDF=$WRFDEPS/view
417+
export JASPERLIB=$WRFDEPS/view/lib64
418+
export JASPERINC=$WRFDEPS/view/include
419+
420+
export CC=mpicc
421+
export FC=mpifort
422+
export CXX=mpic++
423+
424+
cd $WRFROOT/CRYOWRF/WPS-4.2
425+
./configure # choose option 1
426+
427+
# edit configure.wrf to ensure the following variables are set
428+
vim ./configure.wrf
429+
430+
# SFC = gfortran
431+
# SCC = gcc
432+
# DM_FC = mpif90
433+
# DM_CC = mpicc
434+
# FC = gfortran
435+
# CC = gcc
436+
# LD = $(FC)
437+
# FFLAGS = -ffree-form -O -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fallow-invalid-boz
438+
# F77FLAGS = -ffixed-form -O -fconvert=big-endian -frecord-marker=4 -fallow-argument-mismatch -fallow-invalid-boz
439+
440+
./compile &> log_compile
441+
```
442+
268443
Using the same environment as above
269444

270445
```bash
@@ -312,6 +487,18 @@ export WRFROOT=$STORE/wrf
312487
export WRFDEPS=$WRFROOT/dependencies
313488
export LD_LIBRARY_PATH=$WRFDEPS/view/lib:$WRFDEPS/view/lib64:$LD_LIBRARY_PATH
314489

490+
# set WRF variables
491+
export WRF_EM_CORE=1
492+
export WRF_NMM_CORE=0
493+
export WRF_DA_CORE=0
494+
495+
export WRF_CHEM=0
496+
export WRF_KPP=0
497+
498+
export NETCDF4=1
499+
export WRFIO_NCD_LARGE_FILE_SUPPORT=1
500+
export WRFIO_NCD_NO_LARGE_FILE_SUPPORT=0
501+
315502
# set other environment variables
316503

317504
# then run wrf.exe

0 commit comments

Comments
 (0)