[HPC] WRF 기상 모델 시뮬레이션 환경 구축하기

WRF 해석 환경 구축 하기

작성자 : 서진우 ( alang@syszone.co.kr )
작성일 : 2009년 3월 2일

WRF Model 은 MM5 와 함께 전세계적으로 가장 많이 사용하는 대표적인 기상 모델이다.
아래는 MPP 클러스터 환경에서 WRF model을 이용하여 기상 모델 해석을 하는 방법과
WRF 해석 환경 구축에 대해 설명하고자 한다.
WRF를 설치 하기 위해서는 기본적으로 NETCDF가 설치 되어야 한다.

– Netcdf 설치 하기
http://www.unidata.ucar.edu/packages/netcdf
;; WRF 2, 3 버전을 사용할 경우 가능한 netcdf는 3.6.3 버전 이용
;; 4 버전에는 사용하지 못하는 몇몇 기능으로 문제 발생 요소가 존재함.
* PGI compiler
# tar xzvf netcdf-3.6.3.tar.gz
# cd netcdf-3.6.3
# export CC=pgcc
# export F77=pgf77
# export F90=pgf90
# export FC=pgf90
# export CXX=pgCC
# export CFLAGS=”-O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe”
# export CXXFLAGS=”-O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe”
export FFLAGS=”-O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe”
# ./configure –prefix=/usr/local/netcdf3-pgi
# make
# make install
* Intel compiler
 -O3 -mtune=core2 -march=core2 -xT -aT -ip -no-prec-div -no-prec-sqrt -fp-model fast=2
* PGI compiler
-O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe
-O3 -tp p7-64 -pc 64 -Minfo=all -fast -fastsse (권장)

– intel v10
 
export CC=icc
export CXX=icpc
export F77=ifort
export FC=ifort
export CFLAGS=”-O3 -mtune=core2 -march=core2 -xT -axT -ip -no-prec-div”
export CXXFLAGS=”-O3 -mtune=core2 -march=core2 -xT -axT -ip -no-prec-div”
export FFLAGS=”-O3 -mtune=core2 -march=core2 -xT -axT -ip -no-prec-div”
export CPP=’icc -E’
export CXXCPP=’icpc -E’
./configure –prefix=/usr/local/netcdf3-intel
# make
# make install
– intel v9
export CC=icc
export CXX=icpc
export F77=ifort
export FC=ifort
export CFLAGS=”-O3 -xP -axP -ip -no-prec-div”
export CXXFLAGS=”-O3 -xP -axP -ip -no-prec-div”
export FFLAGS=”-O3 -xP -axP -ip -no-prec-div”

– WRF 설치 하기
# tar xzvf WRFV3.0.1.1.TAR.gz
# cd WRFV3
# export NETCDF=/usr/local/netcdf3-<intel,pgi>
# ./configure
checking for perl5… no
checking for perl… found /usr/bin/perl (perl)
Will use NETCDF in dir: /usr/local/netcdf4
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 supported platforms.
   1.  Linux x86_64, PGI compiler with gcc  (serial)
   2.  Linux x86_64, PGI compiler with gcc  (smpar)
   3.  Linux x86_64, PGI compiler with gcc  (dmpar)
   4.  Linux x86_64, PGI compiler with gcc  (dm+sm)
   5.  Linux x86_64 i486 i586 i686, ifort compiler with icc  (serial)
   6.  Linux x86_64 i486 i586 i686, ifort compiler with icc  (smpar)
   7.  Linux x86_64 i486 i586 i686, ifort compiler with icc  (dmpar)
   8.  Linux x86_64 i486 i586 i686, ifort compiler with icc  (dm+sm)
   9.  Linux i486 i586 i686 x86_64, PathScale compiler with pathcc  (serial)
  10.  Linux i486 i586 i686 x86_64, PathScale compiler with pathcc  (dmpar)
  11.  x86_64 Linux, gfortran compiler with gcc   (serial)
  12.  x86_64 Linux, gfortran compiler with gcc   (smpar)
  13.  x86_64 Linux, gfortran compiler with gcc   (dmpar)
  14.  x86_64 Linux, gfortran compiler with gcc   (dm+sm)
  15.  Cray XT Catamount/Linux x86_64, PGI compiler with gcc  (serial)
  16.  Cray XT Catamount/Linux x86_64, PGI compiler with gcc  (dmpar)
  17.  Cray XT CNL/Linux x86_64, PGI compiler with gcc  (serial)
  18.  Cray XT CNL/Linux x86_64, PGI compiler with gcc  (smpar)
  19.  Cray XT CNL/Linux x86_64, PGI compiler with gcc  (dmpar)
  20.  Cray XT CNL/Linux x86_64, PGI compiler with gcc  (dm+sm)
  21.  Cray XT CNL/Linux x86_64, Pathscale compiler with gcc  (serial)
  22.  Cray XT CNL/Linux x86_64, Pathscale compiler with gcc  (smpar)
  23.  Cray XT CNL/Linux x86_64, Pathscale compiler with gcc  (dmpar)
  24.  Cray XT CNL/Linux x86_64, Pathscale compiler with gcc  (dm+sm)
Enter selection [1-24] : 3 or 7 <- MPI 환경에 맞는 번호 선택

그럼 configure.wrf 파일이 생성 된다.
해당 파일을 환경(MPI_PATH)에 맞게 수정한다. CFLAGS, FCFLAGS 등을 최적화 한다.
# vi configure.wrf ( WRFV2 + PGI )
———————————————————————————-
FC              =       /engrid/enhpc/mpich/pgi/bin/mpif90
LD              =       /engrid/enhpc/mpich/pgi/bin/mpif90
CC              =       /engrid/enhpc/mpich/pgi/bin/mpicc -DMPI2_SUPPORT -DFSEEKO64_OK
.
CFLAGS          =       -DDM_PARALLEL -DWRF_RSL_IO \
                        -DMAXDOM_MAKE=$(MAX_DOMAINS) -DMAXPROC_MAKE=$(MAX_PROC) -I../external/RSL/RSL \
                        -DLANDREAD_STUB -O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe
FCFLAGS         =       $(FCOPTIM) $(FCBASEOPTS) -O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe
LDFLAGS         =       -byteswapio -O3 -Mcray=pointer -tp p7-64 -pc 64 -Mnoframe
————————————————————————————
# vi configure.wrf ( WRFV3 + INTEL )
———————————————————————————-
DM_FC           =       /engrid/enhpc/mpich/intel/bin/mpif90 -f90=$(SFC)
DM_CC           =       /engrid/enhpc/mpich/intel/bin/mpicc -cc=$(SCC) -DMPI2_SUPPORT
CFLAGS_LOCAL    =       -w -O3 -ip -mtune=core2 -march=core2 -xT -axT -no-prec-div -no-prec-sqrt -fp-model fast=2
LDFLAGS_LOCAL   =       -ip -mtune=core2 -march=core2 -xT -axT -no-prec-div -no-prec-sqrt -fp-model fast=2
FCFLAGS         =    $(FCOPTIM) $(FCBASEOPTS) $(OMP) -mtune=core2 -march=core2 -xT -axT -no-prec-div -no-prec-sqrt -fp-model fast=2
———————————————————————————-
NETCDF 의 경우 v3 에서 처리 데이터가 2GB 이상 크면 처리하지 못한다. 이때 아래와 같이 환경설정 후
컴파일을 하도록 한다.

# export WRFIO_NCD_LARGE_FILE_SUPPORT=1

이제 아래와 같이 compile 을 수행한다.
해당 case 수행
./compile wrf
./compile em_b_wave
./compile em_grav2d_x
./compile em_heldsuarez
./compile em_hill2d_x
./compile em_les
./compile em_quarter_ss
./compile em_real
./compile em_seabreeze2d_x
./compile em_squall2d_x
./compile em_squall2d_y
그럼 main 디렉토리 밑에 real.exe , ideal.exe, wrf.exe 파일이 생성된다.
해당 파일을 test/case_name 디렉토리와 run 디렉토리에 link 혹은 복사한 후
실행함.

아래는 다양한 컴파일러와 NETCDF 버전, WRF 버전을 조합할 경우 컴파일 성공 여부 결과이다.
WRFV2 + NETCDF3.6 + PGI6.1 + MPICH_PGI -> ok
WRFV3 + NETCDF4 + Intel10 -> ok
WRFV3 + NETCDF3.6 + Intel10 -> ok
WRFV3 + NETCDF3.6 + Intel9 -> ok ( compile 전 ulimit -s unlimited 실행 )
WRFV3 + NETCDF3.6 + PGI6.1 -> fail(compile)
intel compiler 를 이용하여 wrf 실행 시 segment fault 가 발생한다.
real.exe, ideal.exe, wrf.exe 모두 segment fault 발생 가능
이 문제는 OS 의 stack size 를 늘려 줌으로 해결 가능하ㄷ.
# ulimit -s unlimited
or
# vi /root/.bash_profile ->  wrf 사용 계정의 bash 설정에 아래 명령을 포함한다.
ulimit -s unlimited

– WRF 실행하기
1. 가상 테스트 데이터 실행 방법
WPS를 통해 처리된 실제 데이터를 가지고 해석하지 않고, 가상 데이터를 이용하여 해석할
경우 아래 방법을 이용한다.
# cd test/em_b_wave
# ./ideal.exe
rsl.error.0000
rsl.out.0000
파일 생성
# tail -f rsl.error.0000
————————————————————————————
.
wrf: SUCCESS COMPLETE IDEAL INIT
————————————————————————————
# ./wrf.exe
# tail -f rsl.error.0000
————————————————————————————-
.
.
Timing for main: time 0001-01-02_16:30:00 on domain   1:    0.75400 elapsed seconds.
Timing for main: time 0001-01-02_16:40:00 on domain   1:    0.74900 elapsed seconds.
Timing for main: time 0001-01-02_16:50:00 on domain   1:    0.76000 elapsed seconds.
.
d01 0001-01-06_00:00:00 wrf: SUCCESS COMPLETE WRF
————————————————————————————–
wrfout_d01_0001-01-01_00:00:00 파일 생성
일단 실행이 정상적으로 동작되면, mpirun 을 이용한 병렬 실행을 수행한다.
mpirun 실행 방법
# mpirun -np 4 ./ideal.exe
# mpirun -np 4 ./wrf.exe
2. 실제 입력  데이터를 이용한  실행 방법
# cd test/em_real
WPS를 통해 초기 데이터 처리가 완료된 met_em.d01* 입력 데이터들을 해당 디렉토리에 복사
# ./real.exe
# ./wrf.exe
# mpirun -np 4 ./ideal.exe
# mpirun -np 4 ./wrf.exe
아래는 실제 입력 데이터를 이용하여 WRF 해석을 수행하는 과정이다.
# mkdir test001
# cd test001
# cp ../test/em_real/* .
# tar xzvf wps_30km.tar.gz
# vi namelist.input
————————————————————————————-
 history_interval                    = 30,  60,   60,
 time_step                           = 30, -> reduce
————————————————————————————-
# mpirun -np 8 -machinefile ./hosts ./real.exe
# mpirun -np 8 -machinefile ./hosts ./wrf.exe
– namelist.input 수정
runhours : 예보시간
history_interval : 360 -> 6시간 간격으로 출력 (분단위)
time_step : 적분 간격 (10초) (초단위)
dx=3000 ( 3km 격자크기 )
nproc_x : domain decomposition x 방향 셋팅
nproc_y : domain decomposition y 방향 셋팅 ( x * y 는 전체 CPU 수와 동일 )
time mpirun -np 8 -machinefile ./hosts ./wrf.exe
*** org
 run_hours                           = 12,
 history_interval                    = 180
 restart                             = .false.,
 time_step                           = 180,
 dx                                  = 30000, 10000,  3333.33,
real 0m40.382s
user 0m29.496s
sys 0m4.721s
Timing for main: time 2000-01-24_12:03:00 on domain   1:    1.30590 elapsed seconds.
Timing for main: time 2000-01-24_12:06:00 on domain   1:    0.14740 elapsed seconds.
Timing for main: time 2000-01-24_12:09:00 on domain   1:    0.14470 elapsed seconds.
.
.
Timing for main: time 2000-01-24_23:54:00 on domain   1:    0.14550 elapsed seconds.
Timing for main: time 2000-01-24_23:57:00 on domain   1:    0.14290 elapsed seconds.
Timing for main: time 2000-01-25_00:00:00 on domain   1:    0.14580 elapsed seconds.
Timing for Writing wrfout_d01_2000-01-25_00:00:00 for domain        1:    0.11260 elapsed seconds.
 d01 2000-01-25_00:00:00 wrf: SUCCESS COMPLETE WRF
time_step 간격으로 로그 출력 ..
run_hours 정의된 시간범위 만큼 해석
*** modify
 run_hours                           = 24,
real 1m18.386s
user 0m58.338s
sys 0m8.910s
 2000-01-24_12:00:00 부터 2000-01-25_12:00:00 까지 24시간 범위를 해석함.

*** modify
 run_hours                           = 24,
 history_interval                    = 60,  60,   60,
real 1m21.162s
user 0m59.479s
sys 0m9.371s

history_interval 간격으로  wrfout_d01_2000-01-25_10:00:00 결과 파일에 데이터 히스토리 저장
위 설정은 60분 단위로 history를 저장한다. 위 단위가 적으면 적을 수록 I/O가 많이 발생한다.
*** modify
 run_hours                           = 24,
 history_interval                    = 60,  60,   60,
 time_step                           = 10,
Timing for main: time 2000-01-24_12:41:50 on domain   1:    0.13400 elapsed seconds.
Timing for main: time 2000-01-24_12:42:00 on domain   1:    0.13920 elapsed seconds.
Timing for main: time 2000-01-24_12:42:10 on domain   1:    0.13330 elapsed seconds.
time_step (10초 간격으로 해석이 진행 된다. ) 보다 정밀한 해석이 가능할 듯 ..시간은 오래 걸림
real 19m46.272s
user 15m17.832s
sys 1m40.911s

*** modify
 run_hours                           = 24,
 history_interval                    = 180,  60,   60,
 time_step                           = 180,
 dx          = 3000,
 dy          = 3000,
dx 는 수정 불가, 입력 파일에 맞게 지정된 듯 보임

– Performance TEST
WRFV2 + NETCDF3.6 + PGI6.1
example : em_b_vave
np=01 :
real    9m12.041s

WRFV2 + NETCDF3.6 + PGI6.1 (Tuning)
example : em_b_vave
np=01 :
real    8m39.376s
WRFV3 + NETCDF3.6 + INTEL9
example : em_b_vave
np=01 :
real    9m20.041s
WRFV3 + NETCDF4 + INTEL10(tuning)
example : em_b_vave
np=01 :
real 8m25.607s
– WRF 표준 BMT Sample 사용하기 ..
Source : http://www.mmm.ucar.edu/WG2bench/
WRF 외부 BMT는 대부분 BMT 환경에 맞게 WRF source 가 수정된 것이 많다.
해당 사이트에서 제공하는 WRF 버전을 다운 받아 설치 한 후 테스트해야 한다.
sample : conus12km
test/em_real 디렉토리를 BMT 디렉토리로 복사 한다.
conus12km input data 를 BMT 디렉토리에 복사한 후 압축을 푼다.
# tar xzvf conus12km_2001.tar.gz
namelist.input 파일의 domain 항목에 nproc_x, nproc_y 설정을 한다.
mpirun -np xx ./wrf.exe 수행
본 BMT는 대부분 초기 데이터 처리가 완료된 중간 결과 파일을 가지고 restart
하는 방식으로 real.exe 수행이 필요 없다.
WRF 버전과 BMT 소스 버전이 일치 하지 않는 경우 많은 에러가 발생할 것이다.

WRF2.1.1 + PGI
—————————————————————————–
np = 8 : ( 8 )
real    15m23.431s
user    12m49.472s
sys     1m15.405s
np = 8 : ( 4+4 )
real    9m48.950s
user    7m33.824s
sys     0m46.617s

np = 16 : ( 8+8 )
real    8m42.618s
user    6m34.713s
sys     0m44.072s

np = 16 : ( 4+4+4+4 )
real    6m13.332s
user    3m57.352s
sys     0m32.461s

np = 24 :
real    6m12.903s
user    3m51.353s
sys     0m30.909s

np = 32 :
real    5m7.665s
user    2m46.726s
sys     0m25.804s
———————————————————————————-
WRF2.1.1 + PGI (Tuning)
—————————————————————————–
np = 8 : ( 8 )
real    15m3.029s
user    12m37.477s
sys     1m17.623s
np = 8 : ( 4+4 )
real    9m20.313s
user    7m15.167s
sys     0m46.929s

np = 16 : ( 8+8 )
real    8m33.584s
user    6m32.750s
sys     0m44.191s

np = 16 : ( 4+4+4+4 )
real    5m58.665s
user    3m47.805s
sys     0m33.154s
np = 32 :
real    5m4.112s
user    2m45.305s
sys     0m27.504s
—————————————————————————–


WRF3 + INTEL10
———————————————————————————-
np = 8
real    17m24.319s
user    15m38.716s
sys     0m28.522s
np = 16 :
real    9m55.970s
user    7m50.009s
sys     0m28.951s
np = 24 :
real    7m19.692s
user    4m21.800s
sys     0m29.645s
np = 32 :
real    6m3.170s
user    3m8.987s
sys     0m33.342s
———————————————————————————–
ivan01 : 123h_59m_16s
ivan04 : 48h_53m_26s
ivan08 : 42h_28m_51s
ivan(4+4)x1 : 40h_19m_47s
ivan(4+4)x2 : 40h_19m_48s
ivan16 : 23h_56m_12s
ivan32 : 13h_19m_43s

ivan032 : 22h_55m_5s
ivan064 : 23h_38m_17s
ivan128 : 25h_58m_51s

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

4 Responses

  1. gate io 말해보세요:

    For my thesis, I consulted a lot of information, read your article made me feel a lot, benefited me a lot from it, thank you for your help. Thanks!

  2. bossa nova music 말해보세요:

    bossa nova music

  1. 2022년 6월 22일

    3subsides

  2. 2023년 1월 26일

    2consumption

gate io 에 응답 남기기 응답 취소