add computation of tign2ros via grad function
[wrf-fire-matlab.git] / util1_jan / read_array_tiles.m
blob521a2e1a54ba5964d606191ffe0e7fa1b219b41d
1 function a=read_array_tiles(root,tiles,num1,num2);
2 % a=read_array_tiles(root,ntiles,num1,num2)
3 % read array produced by matching calls write_array_m
4 % in module_fr_sfire_util.F
5 % from files root[_num1[_num2]].nnnn.txt,  nnnn=1:ntiles
6 % if tiles=[] same as read_array_sp(root,num1,num2)
8 % Jan Mandel, 2008
10 if ~exist('num1','var'),
11     num1=-1;
12 end
13 if ~exist('num2','var'),
14     num2=-1;
15 end
16 ff=file_name(root,num1,num2);
17 if isempty(tiles),
18     a=read_array_sp([ff,'.txt']);
19     return
20 end
21 for i=1:length(tiles)
22     f=sprintf('%s.%4.4i.txt',ff,tiles(i));
23     tile{i}=full(read_array_sp(f));
24     mm(i)=size(tile{i},1);
25     nn(i)=size(tile{i},2);
26 end
27 m=max(mm);
28 n=max(nn);
29 a=zeros(m,n);
30 for i=1:length(tiles)
31     b=zeros(m,n);
32     b(1:mm(i),1:nn(i))=tile{i};
33     overlap= a(:) ~=0 & b(:)~=0;
34     if(any(overlap)),
35         warning('tiles overlap')
36         if(any(a(overlap) ~= b(overlap))),
37             warning('inconsistent values on overlap')
38         end
39     end
40     
41     a=a+b;
42 end
43 end