


% Testing for parallel matlab toolbox


0001 function [Mobj]=interpolate_polcoms_timeseries_zet(Mobj,polcoms,relaxLine) 0002 %% Testing for parallel matlab toolbox 0003 wasOpened = false; 0004 if license('test', 'Distrib_Computing_Toolbox') 0005 % We have the Parallel Computing Toolbox, so launch a bunch of workers. 0006 if matlabpool('size') == 0 0007 % Force pool to be local in case we have remote pools available. 0008 matlabpool open local 0009 wasOpened = true; 0010 end 0011 end 0012 %% Get info on nodes and elements involved in the nesting layers 0013 oNodes = Mobj.relaxBC_nodes{relaxLine}; 0014 ntimes=polcoms.ntimes; 0015 ndepths=polcoms.ndepths; 0016 % interpolate bathymetry from polcoms onto the FVCOM nodes and elements of 0017 % the nest layer 0018 fdb = TriScatteredInterp(polcoms.xb(:), polcoms.yb(:), polcoms.bathy(:), 'natural'); 0019 polcoms.hb=fdb(Mobj.x(oNodes),Mobj.y(oNodes)); 0020 0021 %% 0022 % 0023 % Extract distance to coast at BC points 0024 % distance has been calculated on the nodes 0025 distbc=Mobj.dist(oNodes); 0026 0027 tic 0028 parfor di = 1:ntimes 0029 % for di = 1:ntimes 0030 % Set up the interpolation objects. 0031 fzet = TriScatteredInterp(polcoms.bcxb(:), polcoms.bcyb(:), polcoms.zet(di,:)', 'natural'); 0032 % Interpolate variables onto the unstructured grid. 0033 tempzet = fzet(Mobj.x(oNodes),Mobj.y(oNodes)); 0034 0035 % fvcom will generally have values outside polcoms domain at the 0036 % coast... we need to extrapolate ... use distance to coast? 0037 if any(isnan(tempzet)) 0038 % split bc into two sides (assumes Boundary is surrounded by coast 0039 % on both sides. 0040 % Find max distance from coast (i.e. middle point) 0041 % Interpolate as a function of distance from coast 0042 % this can go horribly wrong and results should be checked 0043 [tempzet]=interpolate_near_coast(distbc,tempzet,Mobj.doExtrap); 0044 0045 end 0046 0047 % Interpolate single level variables onto the unstructured grid. 0048 fvzet(:, di) =tempzet; % surface elevation on b points 0049 % do depth resolving variable timeseries here 0050 end 0051 % for tt=1:5:ntimes 0052 % figure(1) 0053 % pcolor(repmat(cumsum(distbc),1,size(Mobj.siglayz, 2))',Mobj.siglayz(oNodes, :)',fvtemp(:,:,tt)');colorbar 0054 % pause (0.2) 0055 % end 0056 % 0057 % figure(2) 0058 % pcolor(repmat(cumsum(distbc),1,polcoms.params.n-2)',fvzb(:,:,20)',fvT(:,:,20)');colorbar 0059 if wasOpened 0060 matlabpool close 0061 end 0062 toc 0063 0064 Mobj.zet=fvzet; 0065 0066 return 0067 0068