function [data_nino,time_nino]=compute_nino(data,time,mons);

    [yrs,mos,das]=datevec(time);
    year_all=unique(yrs);
    ind_mon=1:24;
    for l=1:length(year_all)
        tb=datenum(year_all(l),mons(1),1);
        te=datenum(year_all(l),mons(2)+1,1);
        ind=find(time>=tb & time<=te);
        if length(size(data))==2;
           [im,jm]=size(data);
           if im==1 | jm==1;
              data_nino(1:length(ind),l)=data(ind);
           else
              data_nino(1:length(ind),l)=data(:,ind);
           end
        elseif length(size(data))==4;
           data_nino(:,:,:,1:length(ind),l)=data(:,:,:,ind);
        elseif length(size(data))==3;
           data_nino(:,:,1:length(ind),l)=data(:,:,ind);
        else;
           error('data dimensiont is wrong.');
        end
        time_nino(l)=datenum(year_all(l),12,15); %nanmean(time_rain(ind));
    end

end












