integer :: i_parent_start,j_parent_start integer,dimension(2) :: coords coords = minloc((lon0-xlong_m)**2+(lat0-xlat_m)**2) i_parent_start = coords(1) j_parent_start = coords(2)
where xlong_m
and xlat_m
are 2-dimensional arrays that you read from the grid, and lat0
and lon0
are the desired coordinates of the child nest southwest corner. Similarly, if you use Python, you could do:
import numpy as np j_parent_start,i_parent_start = np.unravel_index(\ np.argmin((lon0-xlong_m)**2+(lat0-xlat_m)**2),xlon_m.shape) # Add one because WRF indices start from 1 i_parent_start += 1 j_parent_start += 1
3) Now edit namelist.wps
again, set the i_parent_start
and j_parent_start
to the values that you calculated in step 3, set max_dom = 2
, and re-run geogrid.exe
. The child domain file geo_em.d02.nc
should be created.
4) Look at the geo_em.d02.nc
file. Repeat the procedure until happy with the domain location.
About the parent_grid_ratio
parameter. This is an integer factor of child grid refinement relative to the parent grid. For example, if set to 3, and parent grid resolution is 12 km, the child grid resolution will be 4 km. Odd values for parent_grid_ratio
(3, 5, etc.) are recommended because for even values, interpolation errors arise due to the nature of Arakawa C-grid staggering. parent_grid_ratio = 3
is the most commonly used value, and recommended by myself.
Read in the xlat_m and xlong_m
arrays using java netcdf.
Subtracting desired lat and desired lon from each value of the 2-dimensional xlat_m and xlong_m
arrays and squaring the difference.
Then finding the indices i
and j
of the smallest element of the 2-dimensional array (not as a flattened 1-d array).
There is a tool that comes with WRF called the WRF Domain Wizard that creates the parent and child grids but the issue with this is that you can't see the topography and land use that is so essential for high resolution simulations. In order to view the topography I have another tool that converts the NetCDF file into a KML file and project that on Google Earth. The enclosed image of the child grid is also presented. As explained above for coarse grids this is not so much an issue as it is for nested grids where in the size of the grid itself may not be more than a few hundred meters.
double desiredLatitude = 27; double desiredLongitude = 77; double[][] xlatMArray = getXLatMArray(dataFile); double[][] xlongMArray = getXLongMArray(dataFile); int a = xlatMArray.length; double[][] array = new double[a][a]; for (int i =0 ; i < a;i++) { for (int j =0;j < a ;j++) { double latitudeDiff = desiredLatitude - xlatMArray[i][j]; double longitudeDiff = desiredLongitude - xlongMArray[i][j]; array[i][j]= Math.pow(latitudeDiff,2) + Math.pow(longitudeDiff,2); } } double min = array[0][0]; double max = array[0][0]; int[] minIndex = {0,0}; int[] maxIndex = {0,0}; for (int i =0; i < array.length ; i++) { for (int j =0 ; j < array.length ; j++) { if (array[i][j] < min) { min = array[i][j]; minIndex[0] = i; minIndex[1] = j; } if (array[i][j] > max) { max = array[i][j]; maxIndex[0] = i; maxIndex[1] = j; } } }