https://www2.mmm.ucar.edu/wrf/OnLineTutorial/
Get WRF source code
https://www2.mmm.ucar.edu/wrf/users/download/get_sources_new.php
cd GITWRF
git clone https://github.com/wrf-model/WRF
git clone https://github.com/wrf-model/WPS
Get WPS data (if you don’t already have it):
cd ~/DATA/geog
curl -O https://www2.mmm.ucar.edu/wrf/src/wps_files/geog_high_res_mandatory.tar.gz
Set the Environment
I’d already built the required libraries, but still need to set the environment variables (source GNU-Environment.sh
):
export DIR="/home/conor/Build_WRF/LIBRARIES"
export CC="gcc"
export CXX="g++"
export FC="gfortran"
export FCFLAGS="-m64"
export F77="gfortran"
export FFLAGS="-m64"
export PATH="$DIR/netcdf/bin:$PATH"
export NETCDF="$DIR/netcdf"
export PATH="$DIR/mpich/bin:$PATH"
export LDFLAGS="-L$DIR/grib2/lib"
export CPPFLAGS="-I$DIR/grib2/include"
export JASPERLIB="$DIR/grib2/lib"
export JASPERINC="$DIR/grib2/include"
Compile WRF
./configure
Choose options: GNU dmpar, basic nesting.
You need to edit a file to avoid Errors, probably due to old version of gcc (version 4.4.7) (https://github.com/wrf-model/WRF/issues/1215):
./phys/module_mp_fast_sbm.F
Edit as follows:
line 3726real(kind=r4size) ,intent(in) :: XL(:), COL, RO_SOLUTE,Scale_Fa(:) !modified
Line 3967REAL(kind=r4size),ALLOCATABLE :: Scale_CCN_Factor(:),XCCN(:),RCCN(:),FCCN(:)
Line 6117if (.NOT. ALLOCATED(Scale_CCN_Factor)) ALLOCATE(Scale_CCN_Factor(NKR_aerosol))
Then compile:./compile em_real >& log.compile
Check that executables have been created in the main directory:ls -hl main/*.exe
-rwxrwxr-x 1 conor conor 46M Mar 9 16:57 main/ndown.exe
-rwxrwxr-x 1 conor conor 46M Mar 9 16:57 main/real.exe
-rwxrwxr-x 1 conor conor 45M Mar 9 16:57 main/tc.exe
-rwxrwxr-x 1 conor conor 51M Mar 9 16:56 main/wrf.exe
Compile WPS
Change into the WPS directory and:
./co
nfigure
You need to edit a file for the old version of gcc to compile ungrib.exe:
ungrib/src/read_namelist.F
Edit line 57real, dimension(250) :: new_plvl
Delete line 74:allocate(new_plvl(size(new_plvl_in)))
and delete line 297:deallocate(new_plvl)
Choose option for gfortran serial (1), then compile:./compile >& compile.log
Check that executables have been created:ls -hl *.exe
lrwxrwxrwx 1 conor conor 23 Mar 9 17:23 geogrid.exe -> geogrid/src/geogrid.exe
lrwxrwxrwx 1 conor conor 23 Mar 9 17:24 metgrid.exe -> metgrid/src/metgrid.exe
lrwxrwxrwx 1 conor conor 21 Mar 9 17:23 ungrib.exe -> ungrib/src/ungrib.exe
Run a Test Case
https://www2.mmm.ucar.edu/wrf/OnLineTutorial/CASES/SingleDomain/ungrib.php
Remember to set the environment variables (source GNU-Environment.sh):
Download the data to ~/DATA and extract: ~/DATA/matthew/
Go to ~/GITWRF/WPS and link in the Vtable for GFS:
ln -sf ungrib/Variable_Tables/Vtable.GFS Vtable
Link in the data to create the GRIBFILEs:
./link_grib.csh ~/DATA/matthew/fnl_2016100
Edit namelist.wps:
max_dom = 1
start_date = '2016-10-06_00:00:00',
end_date = '2016-10-08_00:00:00',
interval_seconds = 21600,
Run ./ungrib.exe. This should end with a ! Successful completion of ungrib. ! message and FILE:2016-10… files.
Edit namelist.wps:
e_we = 91,
e_sn = 100,
dx = 27000,
dy = 27000,
map_proj = 'mercator',
ref_lat = 28.00,
ref_lon = -75.00,
truelat1 = 30.0,
truelat2 = 60.0,
stand_lon = -75.0,
geog_data_path = '/home/conor/DATA/geog'
Run ./geogrid.exe. This should end with a ! Successful completion of geogrid. ! message and create the geo_em.d01.nc file.
Run metgrid.exe to interpolate the input data on our model domain: ./metgrid.exe. This should end with the message ! Successful completion of metgrid. ! and create the met_em.d01 files.
Move to the WRF/test/em_real directory and link in the met_em files:
ln -sf ../../../WPS/met_em.d01.2016-10* .
Edit namelist.input:
run_days = 0,
run_hours = 12,
run_minutes = 0,
run_seconds = 0,
start_year = 2016,
start_month = 10,
start_day = 06,
start_hour = 00,
end_year = 2016,
end_month = 10,
end_day = 06,
end_hour = 12,
interval_seconds = 21600
input_from_file = .true.,
history_interval = 180,
frames_per_outfile = 1,
restart = .false.,
restart_interval = 1440,
time_step = 150,
max_dom = 1,
e_we = 91,
e_sn = 100,
e_vert = 45,
num_metgrid_levels = 32
dx = 27000,
dy = 27000,
Run ./real.exe, which should produce wrfinput_d01 and wrfbdy_d01.
Run WRF
qsub the WRF job on ORR2 using a file like this:
#!/bin/bash -l
#$ -S /bin/bash
#$ -pe mpi 4
#$ -cwd
#$ -N oWRF
#$ -V
#################################################
BASEDIR=/home/conor
WRFDIR=${BASEDIR}/GITWRF/WRF/test/em_real
#################################################
# Set environment
source ${BASEDIR}/GITWRF/GNU-Environment.sh
#################################################
date
echo "Starting RUN_WRF"
cd $WRFDIR
rm -f namelist.output rsl.* wrfout*
time mpirun -np 4 ./wrf.exe
echo "FINISHED WRF.EXE"
date
exit 0
On successful completion, the file rsl.out.0000 should end with SUCCESS COMPLETE WRF and you should see wrfout_d01… files.