2 % compute the nearest point in the fire mesh to the given coordinates
3 % use to determine ignition points that lie on the mesh
4 % run this in the directory with your wrfinput file
6 % jan mandel, june 2013
8 d=input('enter domain number: ');
9 f=sprintf('wrfinput_d%02i',d);
10 fprintf('reading file %s\n',f);
11 lon=ncread(f,'FXLONG');
12 lat=ncread(f,'FXLAT');
19 if(m1 ~= m | n1 ~= n),
20 error('inconsistent size of FXLONG and FXLAT')
22 fprintf('loaded mesh size %i by %i coordinates %g to %g by %g to %g\n',m,n,min_x,max_x,min_y,max_y);
23 if(max_x == 0 | max_y == 0)
24 error('Fire mesh coordinates not set. Please use wrfinput file from a current real.exe or ideal.exe')
26 longlat=input('Enter 1=real run or 0=ideal: ');
27 if longlat==0, % ideal
35 fprintf('the center of the domain is at coordinates %g %g\n',lon_ctr,lat_ctr)
36 unit_fxlat=6370*2*pi/360; % one degree latitude in m
37 unit_fxlon=cos(lat_ctr*2*pi/360)*unit_fxlat; % one degree longitude in m
39 fprintf('coordinate units are %g %g m\n',unit_fxlat,unit_fxlon)
42 x=input('enter the 1st coordinate of ignition point (x or longitude), or enter to exit: ');
46 y=input('enter the 2nd coordinate of ignition point (y or latitude), or enter to exit: ');
50 fprintf('entered coordinates %g %g\n',x,y)
51 if (x<min_x | x>max_x | y<min_y | y>max_y),
52 error('the point is outside of the domain')
54 % find the nearest point (lon(i,j),lat(i,j)) to (x,y)
55 d = sqrt((unit_fxlon*(lon-x)).^2 + (unit_fxlat*(lat-y)).^2);
56 [p,q,minvalue]=find(d==min(d(:)));
60 fprintf('nearest mesh point %i %i at coordinates %12.10g %12.10g distance %g\n',...
61 i,j,lon(i,j),lat(i,j),d(i,j))