Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
software:wrf:caviness.new [2024-04-04 13:10] – frey | software:wrf:caviness.new [2024-04-05 12:22] (current) – frey | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Installation of WRF/WPS ====== | ||
+ | This guide is loosely based on the information presented in the [[https:// | ||
+ | |||
+ | As outlined in the [[technical: | ||
+ | |||
+ | * Versions managed by a singular user for that user's private usage | ||
+ | * Home directory, e.g. '' | ||
+ | * Workgroup per-user directory, e.g. '' | ||
+ | * Versions managed for all members of a workgroup | ||
+ | * Workgroup software directory, e.g. '' | ||
+ | |||
+ | In this document the software will be installed for all members of a workgroup. | ||
+ | |||
+ | ===== Prepare Installation Path ===== | ||
+ | |||
+ | To begin, the workgroup is entered and the installation directories are created. | ||
+ | |||
+ | <code bash> | ||
+ | $ workgroup -g «workgroup» | ||
+ | $ WRF_PREFIX=" | ||
+ | $ WRF_VERSION=" | ||
+ | $ mkdir -p " | ||
+ | $ BUILD_DATE=" | ||
+ | </ | ||
+ | |||
+ | Note that depending on the choice of base path (as outlined above) the value of '' | ||
+ | |||
+ | ===== Build Environment ===== | ||
+ | |||
+ | WRF depends on several external libraries, including the NetCDF and NetCDF-Fortran libraries. | ||
+ | |||
+ | <code bash> | ||
+ | $ vpkg_devrequire netcdf-fortran/ | ||
+ | </ | ||
+ | |||
+ | The PNG library must be at least 1.2.50: | ||
+ | |||
+ | <code bash> | ||
+ | $ pkg-config libpng --modversion | ||
+ | 1.5.13 | ||
+ | </ | ||
+ | |||
+ | The Jasper library must be at least 1.900.1: | ||
+ | |||
+ | <code bash> | ||
+ | $ pkg-config jasper --modversion | ||
+ | 1.900.1 | ||
+ | </ | ||
+ | |||
+ | The zip library (zlib) dependency isn't directly needed by WRF but by the NetCDF library to which it is linked. | ||
+ | |||
+ | For the sake of dependencies and build system tests, a directory will be created to the purpose: | ||
+ | |||
+ | <code bash> | ||
+ | $ mkdir -p " | ||
+ | </ | ||
+ | |||
+ | ===== Build Dependencies ===== | ||
+ | |||
+ | Any dependencies would be downloaded and built in the '' | ||
+ | |||
+ | <WRAP center round alert 60%> | ||
+ | The build of the zip library is shown here for illustrative purposes only -- it does **not** need to be built as part of this procedure. | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | $ pushd " | ||
+ | $ wget ' | ||
+ | $ tar -xf zlib-1.3.1.tar.gz | ||
+ | $ pushd zlib-1.3.1 | ||
+ | $ vpkg_require cmake/ | ||
+ | $ mkdir build-${BUILD_DATE} | ||
+ | $ cd build-${BUILD_DATE} | ||
+ | $ CC=icx \ | ||
+ | cmake \ | ||
+ | -DCMAKE_BUILD_TYPE=Release \ | ||
+ | -DCMAKE_INSTALL_PREFIX=" | ||
+ | .. | ||
+ | $ make | ||
+ | $ make install | ||
+ | $ popd | ||
+ | </ | ||
+ | |||
+ | ===== Build System Tests ===== | ||
+ | |||
+ | WRF has two tests to ensure the build system is likely to succees. | ||
+ | |||
+ | <code bash> | ||
+ | $ cd " | ||
+ | $ wget ' | ||
+ | $ tar -xf Fortran_C_NETCDF_MPI_tests.tar | ||
+ | </ | ||
+ | |||
+ | ==== Test 1: Serial ==== | ||
+ | |||
+ | <code bash> | ||
+ | $ ${FC} ${CPPFLAGS} ${FCFLAGS} -c 01_fortran+c+netcdf_f.f | ||
+ | $ ${CC} ${CPPFLAGS} ${CFLAGS} -c 01_fortran+c+netcdf_c.c | ||
+ | $ ${FC} ${CPPFLAGS} ${FCFLAGS} -o 01_fortran+c+netcdf \ | ||
+ | 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o \ | ||
+ | ${LDFLAGS} -lnetcdff -lnetcdf | ||
+ | $ ./ | ||
+ | C function called by Fortran | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ==== Test 2: MPI Parallelism ==== | ||
+ | |||
+ | <code bash> | ||
+ | $ mpif90 ${CPPFLAGS} ${FCFLAGS} -c 02_fortran+c+netcdf+mpi_f.f | ||
+ | $ mpicc ${CPPFLAGS} ${CFLAGS} -c 02_fortran+c+netcdf+mpi_c.c | ||
+ | $ mpif90 ${CPPFLAGS} ${FCFLAGS} -o 02_fortran+c+netcdf+mpi \ | ||
+ | 02_fortran+c+netcdf+mpi_f.o 02_fortran+c+netcdf+mpi_c.o \ | ||
+ | ${LDFLAGS} -lnetcdff -lnetcdf | ||
+ | $ mpirun -np 1 02_fortran+c+netcdf+mpi | ||
+ | C function called by Fortran | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== Download Main Sources ===== | ||
+ | |||
+ | The WRF and WPS source code will be cloned from Github in the versioned source directory and the desired version checked-out: | ||
+ | |||
+ | <code bash> | ||
+ | $ cd " | ||
+ | |||
+ | $ git clone https:// | ||
+ | $ pushd WRF | ||
+ | $ git checkout v4.5.2 | ||
+ | $ git submodule update --init --recursive | ||
+ | $ popd | ||
+ | |||
+ | $ git clone https:// | ||
+ | $ pushd WPS | ||
+ | $ git checkout v4.5 | ||
+ | $ popd | ||
+ | </ | ||
+ | |||
+ | The clone and checkout process will take some time -- these are large source code repositories. | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | For other 4.5.x and newer releases of WRF, the value assigned to '' | ||
+ | </ | ||
+ | |||
+ | ===== Build WRF ===== | ||
+ | |||
+ | For the Jasper library to be included in the program, the WRF configuration system **must** be altered: | ||
+ | |||
+ | <code bash> | ||
+ | $ cd " | ||
+ | $ sed -i ' | ||
+ | </ | ||
+ | |||
+ | Two builds will be done: distributed-memory parallelism (MPI) and serial. | ||
+ | |||
+ | ==== Distributed-Memory Parallel ==== | ||
+ | |||
+ | For the MPI build, the '' | ||
+ | |||
+ | * Option 78: Intel (ifx/icx), " | ||
+ | * 1: Basic nesting | ||
+ | |||
+ | <code bash> | ||
+ | $ ./clean -aa | ||
+ | $ NETCDF=" | ||
+ | JASPERLIB=/ | ||
+ | ./configure | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <code bash> | ||
+ | $ sed -i -e ' | ||
+ | -e ' | ||
+ | -e ' | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Finally, the code can be compiled. | ||
+ | |||
+ | <code bash> | ||
+ | $ NETCDF=" | ||
+ | JASPERLIB=/ | ||
+ | ./compile -j 4 em_real 2>&1 | tee compile-mpi-${BUILD_DATE}.log | ||
+ | </ | ||
+ | |||
+ | Again, a lot of information will be displayed to the terminal as the build proceeds; all of it will also be written to a file with the name '' | ||
+ | |||
+ | < | ||
+ | ========================================================================== | ||
+ | build started: | ||
+ | build completed: Tue Apr 2 16:53:00 EDT 2024 | ||
+ | |||
+ | ---> | ||
+ | |||
+ | -rwxr-xr-x 1 user workgroup 67864392 Apr 2 16:53 main/ | ||
+ | -rwxr-xr-x 1 user workgroup 67779464 Apr 2 16:53 main/ | ||
+ | -rwxr-xr-x 1 user workgroup 67344608 Apr 2 16:53 main/tc.exe | ||
+ | -rwxr-xr-x 1 user workgroup 71494672 Apr 2 16:52 main/ | ||
+ | |||
+ | ========================================================================== | ||
+ | </ | ||
+ | |||
+ | At this point those executables can be installed outside the source directory to '' | ||
+ | |||
+ | <code bash> | ||
+ | $ mkdir -p " | ||
+ | $ for exe in main/*.exe; do | ||
+ | install --mode=0775 " | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | In the future, the distributed-memory parallel variants of the program will be referenced as '' | ||
+ | |||
+ | === Building WPS === | ||
+ | |||
+ | Since the WPS build makes use of the headers and intermediate libraries produced by the WRF build, at this point the user would need to skip to the section on building WPS and choose the same " | ||
+ | |||
+ | ==== Serial ==== | ||
+ | |||
+ | For the serial build, the '' | ||
+ | |||
+ | * Option 76: Intel (ifx/icx) " | ||
+ | * 0: No nesting | ||
+ | |||
+ | <code bash> | ||
+ | $ ./clean -aa | ||
+ | $ NETCDF=" | ||
+ | JASPERLIB=/ | ||
+ | ./configure | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <code bash> | ||
+ | $ sed -i -e ' | ||
+ | -e ' | ||
+ | -e ' | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Finally, the code can be compiled. | ||
+ | |||
+ | <code bash> | ||
+ | $ NETCDF=" | ||
+ | JASPERLIB=/ | ||
+ | ./compile -j 4 em_real 2>&1 | tee compile-serial-${BUILD_DATE}.log | ||
+ | </ | ||
+ | |||
+ | A lot of information will be displayed to the terminal as the build proceeds; all of it will also be written to a file with the name '' | ||
+ | |||
+ | < | ||
+ | ========================================================================== | ||
+ | build started: | ||
+ | build completed: Tue Apr 2 16:33:37 EDT 2024 | ||
+ | |||
+ | ---> | ||
+ | |||
+ | -rwxr-xr-x 1 user workgroup 67864392 Apr 2 16:33 main/ | ||
+ | -rwxr-xr-x 1 user workgroup 67779464 Apr 2 16:33 main/ | ||
+ | -rwxr-xr-x 1 user workgroup 67344608 Apr 2 16:33 main/tc.exe | ||
+ | -rwxr-xr-x 1 user workgroup 71494672 Apr 2 16:32 main/ | ||
+ | |||
+ | ========================================================================== | ||
+ | </ | ||
+ | |||
+ | At this point those executables can be installed outside the source directory to '' | ||
+ | |||
+ | <code bash> | ||
+ | $ mkdir -p " | ||
+ | $ for exe in main/*.exe; do | ||
+ | install --mode=0775 " | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | In the future, the serial variants of the program will be referenced as '' | ||
+ | |||
+ | In the next section WPS will be built, which will make use of the headers and intermediate libraries produced in this step. **Do not alter the WRF source directory!** | ||
+ | |||
+ | ===== Build WPS ===== | ||
+ | |||
+ | The WRF 4.5.2 code has been updated to include support for the Clang-based Intel oneAPI compiler suite -- the configure options selected in the previous section reflected that. However, WPS 4.5 does not offer those options. | ||
+ | |||
+ | Download the {{: | ||
+ | |||
+ | <code bash> | ||
+ | $ cd " | ||
+ | $ wget ' | ||
+ | $ patch -d arch -p1 < intel-oneapi.patch | ||
+ | patching file configure.defaults | ||
+ | </ | ||
+ | |||
+ | Only the serial variant of WPS will be built. | ||
+ | |||
+ | * Option 41: Intel oneAPI " | ||
+ | |||
+ | <code bash> | ||
+ | $ NETCDF=" | ||
+ | JASPERLIB="/ | ||
+ | WRF_DIR=" | ||
+ | ./configure | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | WRF made use of and linked against the NetCDF-Fortran library, but the WPS configure system does not link against that library. | ||
+ | |||
+ | <code bash> | ||
+ | $ sed -i ' | ||
+ | </ | ||
+ | |||
+ | At this point WPS can be built: | ||
+ | |||
+ | <code bash> | ||
+ | $ NETCDF=" | ||
+ | JASPERLIB=/ | ||
+ | WRF_DIR=" | ||
+ | ./compile 2>&1 | tee compile-serial-${BUILD_DATE}.log | ||
+ | </ | ||
+ | |||
+ | If successful, the executables are installed to the '' | ||
+ | |||
+ | <code bash> | ||
+ | $ find . -name \*.exe -type f -exec install --mode=0775 \{\} " | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <code bash> | ||
+ | $ install --mode=0775 link_grib.csh " | ||
+ | </ | ||
+ | |||
+ | ==== Distributed-Memory Parallel ==== | ||
+ | |||
+ | As with the " | ||
+ | |||
+ | <WRAP center round alert 60%> | ||
+ | The following is **only to be substituted for a " | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | $ for exe in $(find . -name \*.exe -type f); do | ||
+ | echo " | ||
+ | install --mode=0775 " | ||
+ | done | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | ./ | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ===== VALET Package Definition ===== | ||
+ | |||
+ | Creating a VALET package to describe the WRF software makes it easy to dynamically configure the runtime environment for computational jobs. The location to which the package definition file is installed depends on the base installation path chosen for WRF: | ||
+ | |||
+ | * Versions managed by a singular user for that user's private usage | ||
+ | * '' | ||
+ | * Versions managed for all members of a workgroup | ||
+ | * '' | ||
+ | |||
+ | Three variable quantities are needed when authoring the VALET package definition for the WRF software built above. | ||
+ | |||
+ | <code bash> | ||
+ | $ printf " | ||
+ | / | ||
+ | 4.5.2 | ||
+ | </ | ||
+ | |||
+ | The third variable is the VALET package that was added to facilitate the build: | ||
+ | |||
+ | * '' | ||
+ | |||
+ | If no VALET package definition file exists, create the file with the following template (filling-in the values indicated by double angle brackets): | ||
+ | |||
+ | <file yaml wrf.vpkg_yaml> | ||
+ | wrf: | ||
+ | prefix: «WRF_PREFIX» | ||
+ | description: | ||
+ | url: " | ||
+ | |||
+ | versions: | ||
+ | " | ||
+ | description: | ||
+ | dependencies: | ||
+ | - netcdf-fortran/ | ||
+ | actions: | ||
+ | - variable: WRF_SRC_DIR | ||
+ | value: ${VALET_PATH_PREFIX}/ | ||
+ | - variable: WPS_SRC_DIR | ||
+ | value: ${VALET_PATH_PREFIX}/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | This template can be downloaded directly to the '' | ||
+ | |||
+ | <code bash> | ||
+ | $ wget -O " | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | If a '' | ||
+ | |||
+ | <code yaml> | ||
+ | " | ||
+ | description: | ||
+ | dependencies: | ||
+ | - netcdf-fortran/ | ||
+ | actions: | ||
+ | - variable: WRF_SRC_DIR | ||
+ | value: ${VALET_PATH_PREFIX}/ | ||
+ | - variable: WPS_SRC_DIR | ||
+ | value: ${VALET_PATH_PREFIX}/ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Using the Package ==== | ||
+ | |||
+ | The package is added to the environment: | ||
+ | |||
+ | <code bash> | ||
+ | $ vpkg_require wrf/4.5.2 | ||
+ | Adding dependency `szip/ | ||
+ | Adding dependency `hdf4/ | ||
+ | Adding dependency `binutils/ | ||
+ | Adding dependency `gcc/ | ||
+ | Adding dependency `intel-oneapi/ | ||
+ | Adding dependency `ucx/ | ||
+ | Adding dependency `openmpi/ | ||
+ | Adding dependency `hdf5/ | ||
+ | Adding dependency `pnetcdf/ | ||
+ | Adding dependency `netcdf/ | ||
+ | Adding dependency `netcdf-fortran/ | ||
+ | Adding package `wrf/4.5.2` to your environment | ||
+ | </ | ||
+ | |||
+ | The executables are now available on the shell' | ||
+ | |||
+ | <code bash> | ||
+ | $ which real.exe | ||
+ | / | ||
+ | |||
+ | $ which mpi_real.exe | ||
+ | / | ||
+ | |||
+ | $ real.exe | ||
+ | forrtl: No such file or directory | ||
+ | forrtl: severe (29): file not found, unit 27, file / | ||
+ | </ | ||
+ | |||
+ | In addition, two variables are set pointing to the respective source directories of WRF and WPS: | ||
+ | |||
+ | <code bash> | ||
+ | $ ls -ld $WRF_SRC_DIR | ||
+ | drwxr-sr-x 22 user workgroup 41472 Apr 4 11:31 / | ||
+ | |||
+ | $ ls -ld $WPS_SRC_DIR | ||
+ | drwxr-sr-x 9 user workgroup 41472 Apr 4 13:00 / | ||
+ | </ |