function [data,YEARS,lon,lat]=get_curvilinear_rcmdata(GCM_DIR,varname,modelname,expname,...
                region_string,FINE_XX,FINE_YY,units,HISTORICAL_YEARS,FUTURE_YEARS,histname);

%GCM_DIR = SD_RCM_DIR;
%varname = char(VAR_NAME(kk));
%modelname=char(MODEL_NAME(MODEL_NUM));
%expname =char(EXP_NAME(EXP_NUM));
%histname=char(HIST_NAME(HIST_NUM));

          %====================================================================
                %get filename
                dir_string=['/',expname,'/',modelname,'_',...
                        expname,'_',varname];
                myHistFile =  [GCM_DIR,dir_string,'_NAMERICA.mat'];
mhist = matfile (myHistFile);
          %====================================================================
	  %     GET SUBSET
          %====================================================================

        %GCM GRID DATA IS FOR:
        load(myHistFile,'lat','lon');

	X_range = 1:size(lat,2);
	Y_range = 1:size(lat,1);
        %===========================================================
	%   EXTRACT DATA
        %===========================================================
	%historic days
        data= mhist.data(Y_range,X_range,1:365,:); %lat,lon,all days, all years
        data = double(data);
	%==============================================================================
	YEARS = size(data,4);
	%==============================================================================
end 
