Yet another tutorial on how to install WRF


Several tutorials on how to install WRF are available online.
Basically the common root is the Official Tutorial from mmm.ucar.
Some other noticeable websites are:
Among the several tutorials you find online I'd like to add another (useless?) guide (or script) I used to automate the compilation of the WRF/WPS systems, with some special notes.

It is definitely a non-exhaustive script and it might have some (hopefully non-destructive errors), so.... 
>>>use at your own risk<<<

The prerequisites are:
  • the netcdf libray (version 4.x) successfully compiled and installed (here in /usr/local)
  • gcc, gfortran (version 5.4.0 or higher)
 #!/bin/bash  
 # It is supposed that you have the following sources files in $SRCDIR  
 # ARWpost_V3.tar.gz        mpich-3.0.4.tar.gz  WRFV3.9.1.1.TAR.gz  
 # DTC_upp_v3.1.1.tar.gz      jasper-1.701.0.tar.gz netcdf-4.1.3.tar.gz zlib-1.2.11.tar.gz  
 # libpng-1.6.34.tar.gz      WPSV3.9.1.TAR.gz  
 # and it is supposed that you're using the same C/Fortran compiler  
 # used to build the NetCDF libray (in /usr/local)  
 # General settings  
 ROOTDIR='whatever/you/like'  
 SRCDIR=$ROOTDIR'/src'  
 export DIR=$ROOTDIR'/build'  
 export NETCDF=/usr/local  
 export CC=gcc  
 export CXX=g++  
 export FC=gfortran  
 export FCFLAGS=-m64  
 export F77=gfortran  
 export FFLAGS=-m64  
 export LDFLAGS=-L$DIR/grib2/lib   
 export CPPFLAGS=-I$DIR/grib2/include  
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DIR/grib2/lib  
 export JASPERLIB=$DIR/grib2/lib  
 export JASPERINC=$DIR/grib2/include  
 # cd to build directory  
 if [ ! -e $DIR ]; then  
  mkdir -p $DIR   
 fi  
 cd $DIR   
 cp -v $SRCDIR/*.gz .   
 # mpich  
 tar xzvf mpich-3.0.4.tar.gz   
 cd mpich-3.0.4  
 ./configure --prefix=$DIR/mpich  
 make > out.make 2>&1  
 make install  
 export PATH=$DIR/mpich/bin:$PATH  
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/mpich/lib  
 # should do this:  
 #echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/mpich/lib" >> $HOME/.bashrc  
 cd ..  
 rm -f mpich-3.0.4.tar.gz  
 # zlib  
 tar xzvf zlib-1.2.11.tar.gz  
 cd zlib-1.2.11/  
 ./configure --prefix=$DIR/grib2  
 make > out.make 2>&1   
 make install   
 cd ..  
 rm -f zlib-1.2.11.tar.gz  
 # libpng  
 tar xzvf libpng-1.6.34.tar.gz  
 cd libpng-1.6.34  
 ./configure --prefix=$DIR/grib2   
 make > out.make 2>&1   
 make install   
 # should do this:  
 #echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DIR/grib2/lib" >> $HOME/.bashrc  
 cd ..   
 rm -f libpng-1.6.34.tar.gz  
 # JasPer  
 tar xzvf jasper-1.701.0.tar.gz  
 cd jasper-1.701.0  
 ./configure --prefix=$DIR/grib2  
 make > out.make 2>&1  
 make install  
 cd ..   
 rm -f jasper-1.701.0.tar.gz  
 # WRF  
 export WRFIO_NCD_LARGE_FILE_SUPPORT=1  
 gunzip WRFV3.9.1.1.TAR.gz   
 tar -xf WRFV3.9.1.1.TAR   
 cd WRFV3   
 ./clean -a   
 cd external/   
 make superclean   
 cd ..   
 echo "34" > input.config  
 echo "" >> input.config  
 ./configure < input.config  
 #then option 35. (dm+sm) GNU (gfortran/gcc)  
 ./compile em_real > compile.out 2>&1  
 rm -f input.config  
 cd ..  
 rm -f WRFV3.9.1.1.TAR.gz WRFV3.9.1.1.TAR  
 # WPS  
 gunzip WPSV3.9.1.TAR.gz   
 tar -xf WPSV3.9.1.TAR   
 cd WPS/  
 echo 1 > input.config  
 ./configure < input.config  
 #then option 1 Linux x86_64, gfortran  (serial)  
 ./compile > compile.out 2>&1  
 rm -f input.config  
 cd ..  
 rm -f WPSV3.9.1.TAR WPSV3.9.1.TAR.gz  
 exit   
 # UPP  
 tar -zxvf DTC_upp_v3.1.1.tar.gz  
 cd UPPV3.1   
 echo 7 > input.config  
 ./configure < input.config  
 #then option 7. Linux x86_64, gfortran compiler (serial)  
 ./compile > compile.out 2>&1   
 rm -f input.config DTC_upp_v3.1.1.tar.gz  
 cd ..  
 exit 0;  


Besides this script, I'd suggest to install also some complementary tools/software:
  • ncview
  • grads 2.0.2 or higher
  • grib2ctl
  • g2ctl
  • eccodes
  • wgrib
  • wgrib2
  • ncl 6.3 or higher
  • arwpost
  • ...

Commenti

Posta un commento

Post popolari in questo blog

How to run the WRF model using ERA5 (on model levels) as initial and boundary conditions

Install the Meso-NH model in a nutshell