function ind=get_llc_index(nx,ny,iface,ix,jy,Yshift,fileIndex)
%----
%function ind=get_llc_index(nx,iface,ix,jy,Yshift)
%
% function to get compact-format index of a single point [ix,jy]
% obtained from individual faces {1-5} of llc grid.  These faces
% are typically obtained either from [a,af]=patchface3D() or
% [a,af]=get_aste_tracer(a,nfx,nfy);
%
% Input:
%   nx     : basic size of llc grid, [45,90,270,450,1180,2160,4320]
%   ny     : ny for determination of fileIndex precision
%   iface  : face, range [1-5]
%   [ix,jy]: individual [x,y] indices on that face
%   Yshift : y-shift of previous 1:iface-1
%            e.g., if iface=3 and global llc270: Yshift=6*nx  =6*270
%                                 aste   llc270: Yshift=nfy(1)=450
%   fileIndex: INDEX_llcXXX.bin file
% Output:
%   ind    : index of INDEX_llc.bin in global compact array. 
%            can then obtain any variable via: 
%            F=readbin(fileIn,[nx ny]);IND=readbin(INDEX_llc[nx].bin,[nx ny]);
%            F_ixjy=F(IND(ind));
%
% ATN.26.jul.2015
%-------

if(exist(fileIndex)==0);
  error('fileIndex does not exist');
else;
  flist=dir(fileIndex);
  precIn=flist.bytes/nx/ny;
  flagIn='';
  if(precIn==4);flagIn='real*4';elseif(precIn==8);flagIn='real*8';end;
  if(length(flagIn)==0);
    fprintf('inside get_llc_index: flagIn is not determined\n');
    error('can not determine input precision of fileIndex');
  else;
    fld2d=readbin(fileIndex,[1 nx*ny],1,flagIn);
    N=max(size(iface));

    for ipt=1:N;
      if(iface(ipt)==4|iface(ipt)==5);
        clear itemp
        itemp=ix(ipt);
        ix(ipt)=jy(ipt);
        jy(ipt)=itemp;
      end;
    end;

    jy=jy+Yshift;
    ind=(jy-1).*nx+ix;
    ind=fld2d(ind);
  end;
end;
return
