領域気象モデルWeathear Research&Forecast model(WRF)をLinux環境に導入する.
環境
UNIXコマンド
Users Guideで示されたコマンドをaptやdnfで導入する.
依存ライブラリ
Users Guideで示されたライブラリのうちnetCDF,MPIのみ導入する.
WPSのv4.4以降,GIRB2関連のパッケージはWPSに含まれているため無くても良い.
環境変数
$NETCDFを設定する
export LANG=C
export NETCDF=$MyLIB/netcdf
コンパイラテスト
UCARのtutorialのコンパイラやMPIのテストスクリプトを実行.
$ gfortran -c 01_fortran+c+netcdf_f.f
$ gcc -c 01_fortran+c+netcdf_c.c
$ gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o \
-L$MyLIB/netcdf/lib -lnetcdff -lnetcdf
$ ./a.out
C function called by Fortran
Values are xx = 2.00 and ii = 1
SUCCESS test 1 fortran + c + netcdf
$ mpif90 -c 02_fortran+c+netcdf+mpi_f.f
$ mpicc -c 02_fortran+c+netcdf+mpi_c.c
$ mpif90 02_fortran+c+netcdf+mpi_f.o \
02_fortran+c+netcdf+mpi_c.o \
-L$MyLIB/netcdf/lib -lnetcdff -lnetcdf
$ mpirun -n 2 ./a.out
WRF
githubからソースを入手.
$ git clone https://github.com/wrf-model/WRF.git
configure
$ ./configure
$ ./configure
checking for perl5... no
checking for perl... found /usr/bin/perl (perl)
Will use NETCDF in dir: /home/ubuntu/MyLIB/netcdf
ADIOS2 not set in environment. Will configure WRF for use without.
HDF5 not set in environment. Will configure WRF for use without.
PHDF5 not set in environment. Will configure WRF for use without.
$JASPERLIB or $JASPERINC not found in environment, configuring to build without grib2 I/O...
------------------------------------------------------------------------
Please select from among the following Linux x86_64 options:
1. (serial) 2. (smpar) 3. (dmpar) 4. (dm+sm) PGI (pgf90/gcc)
5. (serial) 6. (smpar) 7. (dmpar) 8. (dm+sm) PGI (pgf90/pgcc): SGI MPT
9. (serial) 10. (smpar) 11. (dmpar) 12. (dm+sm) PGI (pgf90/gcc): PGI accelerator
13. (serial) 14. (smpar) 15. (dmpar) 16. (dm+sm) INTEL (ifort/icc)
17. (dm+sm) INTEL (ifort/icc): Xeon Phi (MIC architecture)
18. (serial) 19. (smpar) 20. (dmpar) 21. (dm+sm) INTEL (ifort/icc): Xeon (SNB with AVX mods)
22. (serial) 23. (smpar) 24. (dmpar) 25. (dm+sm) INTEL (ifort/icc): SGI MPT
26. (serial) 27. (smpar) 28. (dmpar) 29. (dm+sm) INTEL (ifort/icc): IBM POE
30. (serial) 31. (dmpar) PATHSCALE (pathf90/pathcc)
32. (serial) 33. (smpar) 34. (dmpar) 35. (dm+sm) GNU (gfortran/gcc)
36. (serial) 37. (smpar) 38. (dmpar) 39. (dm+sm) IBM (xlf90_r/cc_r)
40. (serial) 41. (smpar) 42. (dmpar) 43. (dm+sm) PGI (ftn/gcc): Cray XC CLE
44. (serial) 45. (smpar) 46. (dmpar) 47. (dm+sm) CRAY CCE (ftn $(NOOMP)/cc): Cray XE and XC
48. (serial) 49. (smpar) 50. (dmpar) 51. (dm+sm) INTEL (ftn/icc): Cray XC
52. (serial) 53. (smpar) 54. (dmpar) 55. (dm+sm) PGI (pgf90/pgcc)
56. (serial) 57. (smpar) 58. (dmpar) 59. (dm+sm) PGI (pgf90/gcc): -f90=pgf90
60. (serial) 61. (smpar) 62. (dmpar) 63. (dm+sm) PGI (pgf90/pgcc): -f90=pgf90
64. (serial) 65. (smpar) 66. (dmpar) 67. (dm+sm) INTEL (ifort/icc): HSW/BDW
68. (serial) 69. (smpar) 70. (dmpar) 71. (dm+sm) INTEL (ifort/icc): KNL MIC
72. (serial) 73. (smpar) 74. (dmpar) 75. (dm+sm) AMD (flang/clang) : AMD ZEN1/ ZEN2/ ZEN3 Architectures
76. (serial) 77. (smpar) 78. (dmpar) 79. (dm+sm) INTEL (ifx/icx) : oneAPI LLVM
80. (serial) 81. (smpar) 82. (dmpar) 83. (dm+sm) FUJITSU (frtpx/fccpx): FX10/FX100 SPARC64 IXfx/Xlfx
Enter selection [1-83] : 34
------------------------------------------------------------------------
Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]: 1
オプション34と1を選ぶ.番号はバージョンによって異なる.
成功すると
Configuration successful!
(中略)
Testing for NetCDF, C and Fortran compiler
This installation of NetCDF is 64-bit
C compiler is 64-bit
Fortran compiler is 64-bit
It will build in 64-bit
NetCDF version: 4.9.2
Enabled NetCDF-4/HDF-5: yes
NetCDF built with PnetCDF: no
************************** W A R N I N G ************************************
The moving nest option is not available due to missing rpc/types.h file.
Copy landread.c.dist to landread.c in share directory to bypass compile error.
*****************************************************************************
*****************************************************************************
This build of WRF will use NETCDF4 with HDF5 compression
*****************************************************************************
と表示.
エラー情報
fileコマンドをinstallし忘れるとcompileテストで不可解なエラーがでる.2025-01-27その下のWARNINGに従い
$ cp share/landread.c.dist share/landread.c
コンパイルを実行
$ ./compile em_real >& compile.log
main直下に4つの実行ファイルが生成(サイズが0ではないことを確認)されれば成功.
$ ls -lh main/*exe
-rwxr-xr-x 1 ubuntu ubuntu 40M Jan 27 21:58 main/ndown.exe
-rwxr-xr-x 1 ubuntu ubuntu 37M Jan 27 21:58 main/real.exe
-rwxr-xr-x 1 ubuntu ubuntu 36M Jan 27 21:58 main/tc.exe
-rwxr-xr-x 1 ubuntu ubuntu 50M Jan 27 21:56 main/wrf.exe
WPS
githubからソースを入手.
$ git clone https://github.com/wrf-model/WPS.git
$ cd WPS
configureする.ただしgrib2関連のパッケージは他を参照しない.
./configure --build-grib2-libs
1 を選択.
WRFをdmpar(分散メモリ)でコンパイルした場合もserialを選ぶ.
Will use NETCDF in dir: /home/ubuntu/MyLIB/netcdf
Found what looks like a valid WRF I/O library in ../WRF
********************************************************************************
The zlib, libpng, and JasPer libraries will be compiled from source and
installed in /home/ubuntu/MyWRF/WPS/grib2 .
The environment variables JASPERLIB and JASPERINC will be ignored.
********************************************************************************
------------------------------------------------------------------------
Please select from among the following supported platforms.
1. Linux x86_64, gfortran (serial)
2. Linux x86_64, gfortran (dmpar)
3. Linux x86_64, PGI compiler (serial)
4. Linux x86_64, PGI compiler (dmpar)
5. Linux x86_64, PGI compiler, SGI MPT (serial)
6. Linux x86_64, PGI compiler, SGI MPT (dmpar)
7. Linux x86_64, IA64 and Opteron (serial)
8. Linux x86_64, IA64 and Opteron (dmpar)
9. Linux x86_64, Intel oneAPI compilers (serial)
10. Linux x86_64, Intel oneAPI compilers (dmpar)
11. Linux x86_64, Intel Classic compilers (serial)
12. Linux x86_64, Intel Classic compilers (dmpar)
13. Linux x86_64, Intel Classic compilers, SGI MPT (serial)
14. Linux x86_64, Intel Classic compilers, SGI MPT (dmpar)
15. Linux x86_64, Intel Classic compilers, IBM POE (serial)
16. Linux x86_64, Intel Classic compilers, IBM POE (dmpar)
17. Linux x86_64 g95 compiler (serial)
18. Linux x86_64 g95 compiler (dmpar)
19. Cray XE/XC CLE/Linux x86_64, Cray compiler (serial)
20. Cray XE/XC CLE/Linux x86_64, Cray compiler (dmpar)
21. Cray XC CLE/Linux x86_64, Intel Classic compilers (serial)
22. Cray XC CLE/Linux x86_64, Intel Classic compilers (dmpar)
Enter selection [1-22] : 17
------------------------------------------------------------------------
Configuration successful. To build the WPS, type: compile
------------------------------------------------------------------------
Testing for NetCDF, C and Fortran compiler
This installation NetCDF is 64-bit
C compiler is 64-bit
Fortran compiler is 64-bit
コンパイルを実行
$ ./compile >& log.compile
WPS_GEOG
https://www2.mmm.ucar.edu/wrf/users/download/get_sources_wps_geog.html
からダウンロードする。