testing
[wrf-fire-matlab.git] / femwind / femwind_fortran.m
blobe851931c4e1cdddeb3444586a07eaa58c17b64c2
1 function [W,rate]=femwind_fortran(A,X,u0,params)
3 exe  = './fortran/femwind_test.exe';
4 if isfield(params,'run_fortran') && params.run_fortran && exist(exe,'file') 
5     write_array_nd(swap23(X{1}),'X');
6     write_array_nd(swap23(X{2}),'Y');
7     write_array_nd(swap23(X{3}),'Z');
8     write_array_nd(swap23(u0{1}),'u0');
9     write_array_nd(swap23(u0{2}),'v0');
10     write_array_nd(swap23(u0{3}),'w0');
12     write_array(A,'A')
13     
14     % defaults
15     nel = size(X{1})-1;
16     u =zeros(nel);
17     v =zeros(nel);
18     w =zeros(nel);
19     rate=0;   % placeholder
21     try
22         disp(['running ',exe])
23         system(exe);
24         u=swap23(read_array_nd('u'));
25         v=swap23(read_array_nd('v'));
26         w=swap23(read_array_nd('w'));
27         rate=read_array_nd('rate');
28     catch
29         disp([exe,' failed'])
30     end
32     wf = {u,v,w};
33 end
35 if isfield(params,'run_matlab') && params.run_matlab
36     
37     [wm,rate]=femwind_solve(A,X,u0,params)
38 end
40 if exist('wf','var') & exist('wm','var')
42     tol = 10*eps(single(1.));
43     
44     wwwf=cell2mat(uf);
45     wwm=cell2mat(um);
47     err= norm(wwf(:)-wwm(:),inf)/norm(wwm(:));
48     if err < tol
49         fprintf('error %g OK, tol = %g\n',err,tol)
50     else
51         warning(sprintf('error %g too large, tol=%g',err,tol))
52     end
54 end
56 if exist('wm','var')
57     W = wm;
58 end
60 end