#topicpath

* 領域気象モデル [#t92faff1]
** WRF [#f8e57fc0]
*** WRFについての情報 [#g61fc9ab]
-- WRFとは
The &color(red){W};eather &color(red){R};esearch & &color(red){F};orecasting Model のこと。~
現在も開発が進む領域気象モデル。~
ホームページ : http://www.wrf-model.org/index.php ~
(更新 : 2013-03-25 (月) 13:56:23 )~
~
*** WRF 導入準備 [#e1642ebc]
+ 導入の前に
++ ハードウエア環境~
--- CPU~
AMD Phenom(tm) II X6 1065T Processor : 6コア, 2.90 GHz~
~
--- GPGPU~
Nvidia "Geforce GTX 660" with compute capability 3.0~
~
※ なお、GPGPU を WRF に使うことについての[[ここ>http://www.nvidia.co.jp/object/weather_jp.html]]の記述を見ると、一見、圧倒的なパフォーマンスを示しているように見える。~
しかし、よく見ると、Micro Physics のプログラムについてであり、全体のパフォーマンスは 1.25倍であるときちんと書いてある。~
現時点では、WRF 全体で速くなることはほとんどなさそうである。~
~
※ ただし、[[Smiling Life の記事>http://blog.livedoor.jp/rootan2007/archives/51411320.html]]は期待を持たせる。
~
++ ソフトウエア環境~
Debian GNU/Linux (squeeze) で、主な導入済みパッケージは次のとおり。~
| gfortran                                              |4:4.4.5-1|                                             The GNU Fortran 95 compiler|
| gcc                                                   |4:4.4.5-1|                                             The GNU C compiler|
| libnetcdf-dev                                         |1:4.1.1-5|                                             Development kit for NetCDF|
| libnetcdf6                                            |1:4.1.1-5|                                             An interface for scientific data access to large binary data|
| csh                                                   |20070713-2|                                            Shell with C-like syntax, standard login shell on BSD systems|
|libopenmpi-dev                                        |1.4.2-4|                                               high performance message passing library -- header files|
|libopenmpi1.3                                         |1.4.2-4|                                               high performance message passing library -- shared library|
|openmpi-bin                                           |1.4.2-4|                                               high performance message passing library -- binaries|
|openmpi-checkpoint                                    |1.4.2-4|                                               high performance message passing library -- checkpoint support|
|openmpi-common                                        |1.4.2-4|                                               high performance message passing library -- common files|
~
~
++ コンパイラの選択~
~
WRF を Linux 上で動作させるとき、標準でサポートされているコンパイラは、PGI, Intel, Pathscale, gfortran である。~
このうち、無料で利用できるのは Intel と gfortran であり、さらに、「何の対価もなくプログラム開発するときだけ無償」~
とする Intel のコンパイラは使えない。そこで gfortran を使うことになる。(※ ベンチマークで比較することは、いつかやってみよう。)~
~
Open64 というコンパイラの選択肢もある。しかし、情報が極端に少ない。~
~
なお、コンパイラを変更すると、OpenMPI も同じコンパイラでコンパイルしなおす必要があるようだ。このことからしても、~
gfortran を選ぶのはそれほど悪い選択肢ではない。~
~
ここでは、gfortran と Open64 について、可能な範囲で試してみる。~
~
// 現在、Fortran は過去の言語となりつつあり、高性能なコンパイラの選択肢は限られる。まして、~
// 入手価格が低廉であるか、またはゼロであるようなコンパイラは極めて限られてくる。~
+ ソースプログラムの取得
++ ユーザー登録~
WRF は無償で手に入れることができる。しかし、ユーザー登録は必要である。~
http://www.mmm.ucar.edu/wrf/users/download/get_source.html にアクセスしてユーザー登録をする。~
二度目からは、Returning User をクリックすれば、メールアドレスを入力するだけでダウンロードページへつながる。~
(更新 : 2013-03-25 (月) 14:11:54)~
~
++ プログラムの種類~
WRF を利用するために、ソースプログラムをダウンロードしようとすると、いくつかの種類のファイルに分かれている~
ことに気づいて戸惑う。これらのソースプログラムはそれぞれ役割がある。(更新 : 2013-03-25 (月) 14:41:27)~
--- ARW : Advanced Research WRF~
力学計算や放射計算などが組み込まれたソースプログラム。WRF の中核的なプログラム。~
~
--- WPS : WRF Preprocessor System~
現実のデータを ARW に与えるための前処理プログラム。
理想的な地形、簡単な初期条件を用いて計算する場合には不必要である。~
~
--- WRF-DA : WRF Data Assimilation~
データ同化システムのようである。詳しくはわからない。~
~
--- WRF-Chem : ~
大気中の化学物質の輸送を計算するプログラムのようである。詳しくはわからないが、現在は ARW に組み込んで使うようだ。~
~
--- Post-Processing Software : ~
WRF から出力されたものを図にするためのソフトウエア~
~
--- Utilities : ~
その他の補助的なソフトウエア~
~
++ ダウンロード~
--- 本体~
ソフトウエアの種類は上述のとおりなので、とりあえず必要なのは、ARW と Post-Processing Software である。~
とりあえずコンパイルできること、実行できることを確かめるためには、ARW だけでよい。~
http://www.mmm.ucar.edu/wrf/users/download/get_sources.html#V341 から ARW をダウンロードする。~
現時点で、Ver 3.4.1 が最新である。30MB 弱の大きさである。~
(更新 : 2013-03-25 (月) 14:41:27)~
~
--- 更新ファイル~
いくつかの必要な更新ファイルが出ている(cf. [[Known Problems>http://www.mmm.ucar.edu/wrf/users/wrfv3.4/known-prob-3.4.1.html]])。~
対策のとられた日付けが、Ver 3.4.1 のリリースの日(2012年8月16日)よりも前であっても安心してはいけない。~
それほど親切ではないので、確認しながら自分で対策をとる。具体的にはファイルをダウンロードして入れ換える。~
今回の場合( module_mp_radar.F と input_wrf.F )は、全体にあまり影響を与えないように思われるが、気持ちよくするために入れ換える。~
~
また、WRF では実行する度にソースツリーが変更される。そこで、入れ換えた状態のソースツリーを別途保存しておく。~
(更新 : 2013-03-25 (月) 14:58:36)~
~
~
*** WRF 試しの実行まで( gfortran serial で ) [#g20817e2]
++ configure~
コンパイラとして gfortran を選ぶ。また、CPU は一つのコアだけを用いるとして、serial を選択する。~
実際の入力と出力結果~
  [localhost] ~/WRFV3 15:34:15 $ ./configure 
  checking for perl5... no
  checking for perl... found /usr/bin/perl (perl)
  ** WARNING: No path to NETCDF and environment variable NETCDF not set.
  ** would you like me to try to fix? [y]
  y
  Enter full path to NetCDF include directory on your system
  /usr/include
  Enter full path to NetCDF library directory on your system
  /usr/lib
~
  ...(中略)
  ------------------------------------------------------------------------
  Please select from among the following supported platforms.
  
     1.  Linux x86_64, PGI compiler with gcc  (serial)
    ...(中略)
    23.  x86_64 Linux, gfortran compiler with gcc   (serial)
    ...(中略)
  
  Enter selection [1-34] : 23
  ------------------------------------------------------------------------
  Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: 0
  
  Configuration successful. To build the model type compile .
  ...(以下省略)
実際の入力と出力結果は次の通り。&color(red){->};は入力に関係した行であることを意味する。~
 -> [localhost] ~/WRFV3 15:34:15 $ ./configure 
    checking for perl5... no
    checking for perl... found /usr/bin/perl (perl)
    ** WARNING: No path to NETCDF and environment variable NETCDF not set.
    ** would you like me to try to fix? [y]
 -> y
    Enter full path to NetCDF include directory on your system
 -> /usr/include
    Enter full path to NetCDF library directory on your system
 -> /usr/lib
    ...(中略) 
    ------------------------------------------------------------------------
    Please select from among the following supported platforms.
    
       1.  Linux x86_64, PGI compiler with gcc  (serial)
      ...(中略)
      23.  x86_64 Linux, gfortran compiler with gcc   (serial)
      ...(中略)
    
 -> Enter selection [1-34] : 23
    ------------------------------------------------------------------------
 -> Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: 0
    
    Configuration successful. To build the model type compile .
    ...(以下省略)
(更新 : 2013-03-25 (月) 15:48:29)~
~
++ compile~
具体的に実行可能プログラムを作るには、compile コマンドを実行する。
  ./compile
 -> ./compile
すると、こんな理想化条件が実行できます、というメッセージが出てくるので、2次元の海陸風モデルを選んで実行する。
  ./compile em_seabreeze2d_x
 -> ./compile em_seabreeze2d_x
結構な時間をかけてコンパイルすることになる。一番最後に、コンパイルの所要時間が表示された。
  build started:   2013年  3月 25日 月曜日 15:46:02 JST
  build completed: 2013年 3月 25日 月曜日 15:57:42 JST
    build started:   2013年  3月 25日 月曜日 15:46:02 JST
    build completed: 2013年 3月 25日 月曜日 15:57:42 JST
~
なお、選べるサンプルプログラムは次の通り。~
| 次元 | ケースの名称        | 設定                                       |h
|    1  | em_scm_xy           |   single column model, 4 km, full physics      |
|    2  | em_grav2d_x         |   gravity current, 100 m                       |
|    2  | em_hill2d_x         |   flow over a hill, 2 km                       |
|    2  | em_seabreeze2d_x    |   water and land, 2 km, 20km top, full physics |
|    2  | em_squall2d_x       |   squall line, 250 m                           |
|    2  | em_squall2d_y       |   transpose of above problemINITIALIZATION     |
|    3 | em_b_wave           |    baroclinic wave, 100 km                      |
|    3  | em_fire             |   surface fire, 50 m                           |
|    3  | em_heldsuarez       |   global case with polar filtering, 625 km     |
|    3  | em_les              |   large eddy simulation, 100 m                 |
|    3  | em_quarter_ss       |   super cell, 2 km                             |
|    3  | em_tropical_cyclone |   hurricane, 15 km                             |
~
~
++ 実行
  cd test/em_seabreeze2d_x
  csh ./run_me_first.csh
  ./ideal.exe
  time ./wrf.exe
 -> cd test/em_seabreeze2d_x
 -> csh ./run_me_first.csh
 -> ./ideal.exe
 -> time ./wrf.exe
最後に
 d01 2007-06-01_17:00:00 wrf: SUCCESS COMPLETE WRF
   d01 2007-06-01_17:00:00 wrf: SUCCESS COMPLETE WRF
と表示されて実行も終了。time で測った所要時間は次のとおり。
  real	4m59.360s
  user	4m50.266s
    real	4m59.360s
    user	4m50.266s
(更新 : 2013-03-25 (月) 16:15:02)~
~
*** WRF 試しの実行まで( gfortran dampr で ) [#g20817e2]
*** WRF 試しの実行まで( gfortran dmpar で ) [#g20817e2]
++ configure~
コンパイラとして gfortran を選ぶ。また、CPU の複数コアを用いる MPI を利用するとして、dampr を選択する。~
実際の入力と出力結果(ほとんど省略)~
  [localhost] ~/WRFV3 15:34:15 $ ./configure 
  ...(中略)
  ------------------------------------------------------------------------
  Please select from among the following supported platforms.
  
     1.  Linux x86_64, PGI compiler with gcc  (serial)
 -> [localhost] ~/WRFV3 15:34:15 $ ./configure 
    ...(中略)
    25.  x86_64 Linux, gfortran compiler with gcc   (dmpar)
    ...(中略)
  
  Enter selection [1-34] : 25
  ------------------------------------------------------------------------
  ...(以下省略)
    ------------------------------------------------------------------------
    Please select from among the following supported platforms.
    
       1.  Linux x86_64, PGI compiler with gcc  (serial)
      ...(中略)
      25.  x86_64 Linux, gfortran compiler with gcc   (dmpar)
      ...(中略)
    
 -> Enter selection [1-34] : 25
    ------------------------------------------------------------------------
    ...(以下省略)
~
++ compile~
2次元の海陸風モデルは、MPIに対応していない。そこで、3次元の傾圧不安定波を選んで実行する。
  ./compile em_b_wave
 -> ./compile em_b_wave
結構な時間をかけてコンパイルすることになる。一番最後に、コンパイルの所要時間が表示された。
  build started:   2013年  3月 25日 月曜日 17:19:28 JST
  build completed: 2013年 3月 25日 月曜日 17:31:53 JST
    build started:   2013年  3月 25日 月曜日 17:19:28 JST
    build completed: 2013年 3月 25日 月曜日 17:31:53 JST
~
++ 実行
  cd test/em_b_wave
  csh ./run_me_first.csh
  mpirun -n 5 ./ideal.exe
  time mpirun -n 5 ./wrf.exe
 -> cd test/em_b_wave
 -> csh ./run_me_first.csh
 -> mpirun -n 5 ./ideal.exe
 -> time mpirun -n 5 ./wrf.exe
ログは表示されない。mpirun を使って実行するところがミソ。この場合、5個のコアを使っている。time で測った所要時間は次のとおり。
  real	3m21.428s
  user	16m32.850s
  sys	0m2.952s
同じプログラムを serial で実行すると、2〜3倍の速さで動いていることがわかる。
  real	9m19.641s
  user	9m2.306s
  sys	0m14.033s
    real	3m21.428s
    user	16m32.850s
    sys	0m2.952s
同じプログラムを serial で実行すると、dmpar では2〜3倍の速さで動いていることがわかる。
    real	9m19.641s
    user	9m2.306s
    sys	0m14.033s
(更新 : 2013-03-25 (月) 18:37:30)~
~


トップ   新規 検索 最終更新   ヘルプ   最終更新のRSS