領域気象モデルWRFの依存パッケージを任意のディレクトリに導入する.
参考にしたサイト:
docker環境にWRFを導入
WRFのインストールスクリプト
実行環境
dockerで構築したUbuntu.
Linuxサーバ上の適当なディレクトリにcompose.yamlとvolumeを作成
compose.yaml
services:
ubuntu:
image: ubuntu:24.04
container_name: ubuntu_wrf
tty: true
volumes:
- ubuntu_wrf_volume:/home/ubuntu
volumes:
ubuntu_wrf_volume:
driver_opts:
type: none
device: ${PWD}/ubuntu_wrf_volume
o: bind
rootユーザでログイン
$ docker compose exec ubuntu /bin/bash
aptの更新・sudoのインストール
# apt update
# apt install sudo
# exit
自動で作成される一般ユーザ"ubuntu"でログイン
$ docker compose exec -u ubuntu ubuntu /bin/bash
各種パッケージの導入
$ sudo apt install csh
$ sudo apt install file
$ sudo apt install wget
$ sudo apt install make
$ sudo apt install curl
$ sudo apt install libcurl4-openssl-dev
$ sudo apt install gcc
$ sudo apt install g++
$ sudo apt install gfortran
$ sudo apt install libxml2-dev
ZLIB,HDF5,netCDF,openMPIの導入
v4.4以降のWPSは,zlib, libpng, and JasPerが内部に含まれているため,新たに導入しなくてもよい(Users Guide).
そのため,一般的なWRFの構築に最低限必要なライブラリは
- ZLIB(HDF5に必要)
- HDF5(netCDFに必要)
- netCDF(netcdf-c,netcdf-fortran)
- openMPIまたはMPICH(どちらか)
となる.
コンパイラ
C/C++のコンパイラにgcc,fortranのコンパイラにgfortranを使用する.
WRFのコンパイルと同じものを使う.
ディレクトリ
ライブラリは自分で指定したディレクトリに導入する.
export MyLIB= wrf_library_directory
ZLIB
データ圧縮・展開のためのライブラリ.
(zlib.net)からソースを入手・展開
$ cd $MyLIB
$ wget https://www.zlib.net/zlib-1.3.1.tar.gz
$ tar xzvf zlib-1.3.1.tar.gz
$ cd zlib-1.3.1
フラグ一覧
$ configure --help
usage:
configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]
[--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]
[--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]
configure&make
$ ./configure --prefix=$MyLIB/zlib
$ make
$ make install
パスを通す
export PATH=$MyLIB/zlib/bin:$PATH
export LD_LIBRARY_PATH=$MyLIB/zlib/lib:$LD_LIBRARY_PATH
HDF5
LDFLAGS(リンカのオプション),CPPFLAGS(C/C++のプリプロセッサのフラグ)にzlibの各ファイルを指定.
LDFLAGS="-L$MyLIB/zlib/lib"
export CPPFLAGS="-I$MyLIB/zlib/include"
githubのreleaceからソースを入手
$ wget https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.5/hdf5-1.14.5.tar.gz
フラグ一覧
$ ./configure --help
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
FC Fortran compiler command
FCFLAGS Fortran compiler flags
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CXXCPP C++ preprocessor
DOXYGEN_PAPER_SIZE
a4wide (default), a4, letter, legal or executive
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
フラグの設定
export LDFLAGS="-L$MyLIB/zlib/lib"
export CPPFLAGS="-I$MyLIB/zlib/include -fcommon"
export FCFLAGS="-m64 -fallow-argument-mismatch"
export CC=gcc
export CXX=g++
export FC=gfortran
configure&make
$ ./configure --prefix=$MyLIB/hdf5 --with-zlib=$MyLIB/zlib --enable-fortran --enable-shared
$ make
$ make install
パスを通す
export PATH=$MyLIB/hdf5/bin:$PATH
export LD_LIBRARY_PATH=$MyLIB/hdf5/bin:$LD_LIBRARY_PATH
netcdf-c
LDFLAGS,CPPFLAGSの更新
LDFLAGS="-L$MyLIB/zlib/lib -L$MyLIB/hdf5/lib"
export CPPFLAGS="-I$MyLIB/zlib/include"
uni-dataのgithubからソースを入手
$ wget https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netcdf-c-4.9.2.tar.gz
フラグ一覧
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
CXXCPP C++ preprocessor
CPP C preprocessor
フラグの設定
export LDFLAGS="-L$MyLIB/zlib/lib -L$MyLIB/hdf5/lib"
export CPPFLAGS="-I$MyLIB/zlib/include -I$MyLIB/hdf5/include -fcommon"
export FCFLAGS="-m64 -fallow-argument-mismatch"
export FFLAGS="-m64 -fallow-argument-mismatch"
export CC=gcc
export CXX=g++
export FC=gfortran
configure&make
$ ./configure --prefix=$MyLIB/netcdf --enable-netcdf4 --enable-hdf5 --enable-shared
$ make
$ make install
パスを通す
export PATH=$MyLIB/netcdf/bin:$PATH
export LD_LIBRARY_PATH=$MyLIB/netcdf/lib:$LD_LIBRARY_PATH
netcdf-fortran
LDFLAGS,CPPFLAGSの更新
LDFLAGS="-L$MyLIB/zlib/lib -L$MyLIB/hdf5/lib"
export CPPFLAGS="-I$MyLIB/zlib/include"
netcdf-cと同じページからソースを入手
$wget https://downloads.unidata.ucar.edu/netcdf-fortran/4.6.1/netcdf-fortran-4.6.1.tar.gz
フラグ一覧
$ ./configure --help
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
FC Fortran compiler command
FCFLAGS Fortran compiler flags
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
フラグの設定
export LDFLAGS="-L$MyLIB/zlib/lib -L$MyLIB/hdf5/lib -L$MyLIB/netcdf/lib"
export CPPFLAGS="-I$MyLIB/zlib/include -I$MyLIB/hdf5/include -I$MyLIB/netcdf/include -fcommon"
export FCFLAGS="-m64 -fallow-argument-mismatch"
export FFLAGS="-m64 -fallow-argument-mismatch"
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
configure&make
$ ./configure --prefix=$MyLIB/netcdf --enable-shared
$ make
$ make install
openMPI
並列計算のMPIのためのライブラリ.
open-mpi.orgの「Download」からソースを入手
$ wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.6.tar.gz
$ tar xzvf openmpi-5.0.6.tar.gz
$ cd openmpi-5.0.6
フラグ一覧
$ ./configure --help
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CXXCPP C++ preprocessor
CCAS assembler compiler command (defaults to CC)
CCASFLAGS assembler compiler flags (defaults to CFLAGS)
FC Fortran compiler command
FCFLAGS Fortran compiler flags
CPP C preprocessor
フラグの設定
export LDFLAGS="-L$MyLIB/zlib/lib -L$MyLIB/hdf5/lib -L$MyLIB/netcdf/lib"
export CPPFLAGS="-I$MyLIB/zlib/include -I$MyLIB/hdf5/include -I$MyLIB/netcdf/include -fcommon"
export FCFLAGS="-m64 -fallow-argument-mismatch"
export CC=gcc
export CXX=g++
export FC=gfortran
LDFLAGS,CPPFLAGSはいずれもzlibのみ参照すれば良いと思われる.
(zlibの前にopenMPiをinstallした際,WRFのコンパイルテストのスクリプトを実行すると以下のWarningが表示された)
-------------------------------------------------------------------------
PMIx was unable to find a usable compression library
on the system. We will therefore be unable to compress
large data streams. This may result in longer-than-normal
startup times and larger memory footprints. We will
continue, but strongly recommend installing zlib or
a comparable compression library for better user experience.
You can suppress this warning by adding "pcompress_base_silence_warning=1"
to your PMIx MCA default parameter file, or by adding
"PMIX_MCA_pcompress_base_silence_warning=1" to your environment.
--------------------------------------------------------------------------
configure&make
$./configure --prefix=$MyLIB/openmpi CC=gcc CXX=g++ FC=gfortran
$ make
$ make install
パスを通す.
export PATH=$MyLIB/openmpi/bin:$PATH
export LD_LIBRARY_PATH=$MyLIB/openmpi/lib:$LD_LIBRARY_PATH
終わりに
ライブラリの導入に用いたLDFLAGS,CPPFLAGSなどのフラグはいずれもWRFのコンパイルに使わないため,~/.bashrc等に記載している場合は削除