登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Centos7.3安装wrf3.8.1经验总结 2017.8.7(如果有不懂的请联系我,联系的时候请说明情况,QQ823800859) 参考的主要方式如下红色链接: http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php#STEP1 1.系统及主要软件版本 1.1系统:CentOS Linuxrelease 7.3.1611 (Core) 查看命令 cat /etc/redhat-release 1.2 WRF:V3.8.1 1.3 cpp\gcc\g++\gfortran:4.8.5 1.3.1查看是否安装了上述三个必要编译器: which gfortran which cpp which gcc 1.3.2查看版本号: gcc --version gfortran --version cpp --version 1.4 所需要的所有软件库和图书库: mpich-3.0.4
netcdf-4.1.3
Jasper-1.900.1 libpng-1.2.50 zlib-1.2.7
1.4.1 mpich-3.0.4 http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/mpich-3.0.4.tar.gz 1.4.2 netcdf-4.1.3 http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/mpich-3.0.4.tar.gz 1.4.3 Jasper-1.900.1 http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/netcdf-4.1.3.tar.gz 1.4.4 libpng-1.2.50 http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/jasper-1.900.1.tar.gz 1.4.5 zlib-1.2.7 http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/zlib-1.2.7.tar.gz 1.5上述安装过程 1.5.1NetCDF: This library is alwaysnecessary! setenv DIRpath_to_directory/Build_WRF/LIBRARIES setenv CC gcc setenv CXX g++ setenv FC gfortran setenv FCFLAGS -m64 setenv F77 gfortran setenv FFLAGS -m64 tar xzvf netcdf-4.1.3.tar.gz #or just .tar if no .gz present cd netcdf-4.1.3 ./configure --prefix=$DIR/netcdf--disable-dap \ --disable-netcdf-4 --disable-shared make make install setenv PATH $DIR/netcdf/bin:$PATH setenv NETCDF $DIR/netcdf cd .. 1.5.2MPICH: This library is necessary if youare planning to build WRF in parallel. If your machine does not have more than1 processor, or if you have no need to run WRF with multiple processors, youcan skip installing MPICH. In principle, anyimplementation of the MPI-2 standard should work with WRF; however, we have themost experience with MPICH, and therefore, that is what will be described here. Assuming all the'setenv' commands were already issued while setting up NetCDF, you can continueon to install MPICH, issuing each of the following commands: tar xzvf mpich-3.0.4.tar.gz #or just .tar if no .gz present cd mpich-3.0.4 ./configure --prefix=$DIR/mpich make make install setenv PATH $DIR/mpich/bin:$PATH cd .. 1.5.3zlib: This is a compression librarynecessary for compiling WPS (specifically ungrib) with GRIB2 capability Assuming all the"setenv" commands from the NetCDF install are already set, you canmove on to the commands to install zlib. setenv LDFLAGS -L$DIR/grib2/lib setenv CPPFLAGS -I$DIR/grib2/include tar xzvf zlib-1.2.7.tar.gz #or just .tar if no .gz present cd zlib-1.2.7 ./configure --prefix=$DIR/grib2 make make install cd .. 1.5.4libpng: This is a compression librarynecessary for compiling WPS (specifically ungrib) with GRIB2 capability Assuming all the"setenv" commands from the NetCDF install are already set, you canmove on to the commands to install zlib. tar xzvf libpng-1.2.50.tar.gz #or just .tar if no .gz present cd libpng-1.2.50 ./configure --prefix=$DIR/grib2 make make install cd .. 1.5.5JasPer: This is a compression librarynecessary for compiling WPS (specifically ungrib) with GRIB2 capability Assuming all the"setenv" commands from the NetCDF install are already set, you canmove on to the commands to install zlib. tar xzvf jasper-1.900.1.tar.gz #or just .tar if no .gz present cd jasper-1.900.1 ./configure --prefix=$DIR/grib2 make make install cd .. 2. LibraryCompatibility Tests - Once the target machine is able to make small Fortran and C executables (what was verified in the System Environment Tests section), and after the NetCDF and MPI libraries are constructed (two of the libraries from the Building Libraries section), to emulate the WRF code's behavior, two additional small tests are required. We need to verify that the libraries are able to work with the compilers that are to be used for the WPS and WRF builds. Below is a tar file that contans these tests. Download this tar file and place it in the TESTS directory:
Fortran_C_NETCDF_MPI_tests.tar To unpack the tar file, type: tar -xf Fortran_C_NETCDF_MPI_tests.tar - There are 2 tests:
- Test #1: Fortran + C + NetCDF
The NetCDF-only test requires the include file from the NETCDF package be in this directory. Copy the file here:
cp ${NETCDF}/include/netcdf.inc . Compile the Fortran and C codes for thepurpose of this test (the -c option says to not try to build an executable).Type the following commands: 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${NETCDF}/lib -lnetcdff -lnetcdf
./a.out The following should be displayed on yourscreen: C function called by Fortran
Values are xx = 2.00 and ii = 1
SUCCESS test 1 fortran + c + netcdf
- Test #2: Fortran + C + NetCDF + MPI
The NetCDF+MPI test requires include files from both of these packages be in this directory, but the MPI scripts automatically make the mpif.h file available without assistance, so no need to copy that one. Copy the NetCDF include file here:
cp ${NETCDF}/include/netcdf.inc . Note that the MPI executables mpif90 and mpicc are usedbelow when compiling. Issue the following commands: 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${NETCDF}/lib -lnetcdff -lnetcdf
mpirun ./a.out The following should be displayed on yourscreen: C function called by Fortran
Values are xx = 2.00 and ii = 1
status = 2
SUCCESS test 2 fortran + c + netcdf + mpi 3. Building WRFV3 After ensuring that all libraries arecompatible with the compilers, you can now prepare to build WRFV3. If you donot already have a WRFV3 tar file, you can find it below. Download that fileand unpack it in the Build_WRF directory. WRFV3.8.1 gunzip WRFV3.8.1.TAR.gz tar -xf WRFV3.8.1.TAR Go into the WRFV3 directory: cd WRFV3 Create a configuration file for yourcomputer and compiler: ./configure You will see various options. Choose theoption that lists the compiler you are using and the way you wish to buildWRFV3 (i.e., serially or in parallel). Although there are 3 different types ofparallel (smpar, dmpar, and dm+sm), we have the most experience with dmpar andtypically recommend choosing this option. Once your configuration is complete, youshould have a configure.wrf file, and you are ready to compile. To compileWRFV3, you will need to decide which type of case you wish to compile. Theoptions are listed below: em_real (3d real case) em_quarter_ss (3d ideal case) em_b_wave (3d ideal case) em_les (3d ideal case) em_heldsuarez (3d ideal case) em_tropical_cyclone (3d ideal case) em_hill2d_x (2d ideal case) em_squall2d_x (2d ideal case) em_squall2d_y (2d ideal case) em_grav2d_x (2d ideal case) em_seabreeze2d_x (2d ideal case) em_scm_xy (1d ideal case) ./compile case_name >&log.compile where case_name is one of the optionslisted above Compilation should take about 20-30minutes. Once the compilation completes, to checkwhether it was successful, you need to look for executables in the WRFV3/maindirectory: ls -ls main/*.exe If you compiled a real case, you shouldsee: wrf.exe (model executable) real.exe (real data initialization) ndown.exe (one-way nesting) tc.exe (for tc bogusing--serial only) If you compiled an idealized case, youshould see: wrf.exe (model executable) ideal.exe (ideal case initialization) These executables are linked to 2 differentdirectories: WRFV3/run WRFV3/test/em_real You can choose to run WRF from either directory. 4. Building WPS After the WRFmodel is built, the next step is building the WPS program (if you plan to runreal cases, as opposed to idealized cases). The WRF model MUST be properlybuilt prior to trying to build the WPS programs. Below is a tar file containingthe WPS source code. Download that file and unpack it in the Build_WRFdirectory: WPSV3.8.1 gunzip WPSV3.8.1.TAR.gz tar -xf WPSV3.8.1.TAR Go into the WPSdirectory: cd WPS Similar to the WRFmodel, make sure the WPS directory is clean, by issuing: ./clean The next step isto configure WPS, however, you first need to set some paths for the ungriblibraries: setenv JASPERLIB $DIR/grib2/lib setenv JASPERINC $DIR/grib2/include and then you canconfigure: ./configure You should begiven a list of various options for compiler types, whether to compile inserial or parallel, and whether to compile ungrib with GRIB2 capability. Unlessyou plan to create extremely large domains, it is recommended to compile WPS inserial mode, regardless of whether you compiled WRFV3 in parallel. It is alsorecommended that you choose a GRIB2 option (make sure you do not choose onethat states "NO_GRIB2"). You may choose a non-grib2 option, but mostdata is now in grib2 format, so it is best to choose this option. You can stillrun grib1 data when you have built with grib2. Choose the optionthat lists a compiler to match what you used to compile WRFV3, serial, andgrib2. **Note: The option number will likely be different than the number youchose to compile WRFV3 the metgrid.exeand geogrid.exe programs rely on the WRF model's I/O libraries. There is a linein the configure.wps file that directs the WPS build system to the location ofthe I/O libraries from the WRF model: WRF_DIR = ../WRFV3 Above is thedefault setting. As long as the name of the WRF model's top-level directory is"WRFV3" and the WPS and WRFV3 directories are at the same level(which they should be if you have followed exactly as instructed on this pageso far), then the existing default setting is correct and there is no need tochange it. If it is not correct, you must modify the configure file and thensave the changes before compiling. You can nowcompile WPS: ./compile >& log.compile Compilation shouldonly take a few minutes. If the compilationis successful, there should be 3 main executables in the WPS top-leveldirectory: geogrid.exe ungrib.exe metgrid.exe Verify that theyare not zero-sized. To see file size, you can type: ls -ls *.exe
|