%---------------------------------------------------------------------
function [cldLat, cldLon, ctp, wfrc,wcod,wcre, ifrc,icod,icre, tfrc] = ...
    get_cloud( iyr, imon, idy, hrmin, doy, satName, inPath0);
%---------------------------------------------------------------------

yyyy = num2str(iyr,  '%04d');
mm   = num2str(imon, '%02d');
dd   = num2str(idy,  '%02d');
ddd  = num2str(doy,  '%03d');
hhmm = num2str(hrmin,'%04d');


%-- spectial cases
%terra20051261705 = strcmp(satName,'terra') &&...
%                   iyr==2005 &&...
%                   doy==126 &&...
%                   hrmin==1705; %cloud drop size has problem!

inPath = [inPath0,'cloud/',yyyy,'/',satName,'/'];
inFileName = [inPath,'cld.',satName,'.',yyyy,ddd,'.',hhmm,'.dat'];
fid = fopen(inFileName,'r');
 cldNDims = fread(fid, 1, 'int32');
 cldDims  = fread(fid, cldNDims,  'int32');
 cldLat   = fread(fid, prod(cldDims), 'float32');
 cldLon   = fread(fid, prod(cldDims), 'float32');
 ctp      = fread(fid, prod(cldDims), 'float32');
 wfrc     = fread(fid, prod(cldDims), 'float32');
 wcre     = fread(fid, prod(cldDims), 'float32');
 wcod     = fread(fid, prod(cldDims), 'float32');
 ifrc     = fread(fid, prod(cldDims), 'float32');
 icre     = fread(fid, prod(cldDims), 'float32');
 icod     = fread(fid, prod(cldDims), 'float32');
 tfrc     = fread(fid, prod(cldDims), 'float32');
fclose(fid);


cldDims = cldDims';
cldLat = reshape(cldLat, cldDims);
cldLon = reshape(cldLon, cldDims);
ctp    = reshape(ctp,    cldDims);
wfrc   = reshape(wfrc,   cldDims);
wcre   = reshape(wcre,   cldDims);
wcod   = reshape(wcod,   cldDims);
ifrc   = reshape(ifrc,   cldDims);
icre   = reshape(icre,   cldDims);
icod   = reshape(icod,   cldDims);
tfrc   = reshape(tfrc,   cldDims);

%keyboard   
end