function fieldOut=get_3d_85klev(prof_point,model_z,prof_z,fileIn,mskC)
%----------------------
% function fieldOut=get_3d_85klev(prof_point,model_z,prof_z,fileIn,mskC)
%
% function to extract profiles from any 3D fields , then interpolate in z-dir
%
% Input:
%   prof_point: locations (jy-1)*nx+ix of profiles, size N x 1 (or 1 x N)
%   model_z   : zlevel of 3D field in fileIn,       size nz x 1 (or 1 x nz)
%   prof_z    : zlevel of profiles		    size K x 1 (or 1 x K)
%   fileIn    : full name (directory+name) of 3D field  (size nx * ny * nz)
%   mskC      : same size as 3D field, to be applied to 3D field  
%               to avoid bogus values at the bottom     (size nx * ny *nz)
% Output:
%   fieldOut  : size N x K
%
% atn Nov 2016, vonana Nov 2016
% atn Feb 2017: add maskC
%----------------------

%define model size
nx=270;

N  = length(prof_point);
K  = length(prof_z);    %85
nz = length(model_z);   %50

fieldOut =zeros(N,K);
temp0    =zeros(N,nz);

%precIn = 'real*4';
for kz=1:nz;
  sigma=read_slice(fileIn,nx,nx*13,kz).*mskC(:,:,kz);
  sigma=patchface3D(nx,nx*13,1,sigma,2);              %size [4*nx 4*nx nz]

%now extract horizontal points:
  temp0(:,kz)=sigma(prof_point);                %size N x 50
end;

%now interp to 85klev:
for ipt=1:N
  fieldOut(ipt,:)=interp1(model_z,temp0(ipt,:),prof_z,'linear');
end

return

