a1 = 'westWAOR_1970-2099_p';
vdata = [];
lats = [];
lons = [];

for i = 1:68
	c = sprintf('%02d', i);
   file = strcat(a1,c,'.nc');	
   disp(file);
    
	var = ncread(file, 'PREC');
	lat = ncread(file, 'lat');
	lon = ncread(file, 'lon');
	
	vdata = cat(2, vdata, var);
	lats = cat(2, lats, lat);
	lons = cat(2, lons, lon);
	 
end

times = ncread(file, 'Times');
%times = round(times/10000)
disp(size(vdata));
sz = size(vdata);
out = 'x.nc';

nccreate(out,'PREC',...
   'Dimensions',{'x',sz(1),'y',sz(2),'Times',sz(3)},...
   'Format','netcdf4');
	
nccreate(out,'Times',...
   'Dimensions',{'Times',sz(3)},...
   'Format','netcdf4');
	
nccreate(out,'lat',...
   'Dimensions',{'x',sz(1), 'y', sz(2)},...
   'Format','netcdf4');
	
nccreate(out,'lon',...
   'Dimensions',{'x',sz(1), 'y', sz(2)},...
   'Format','netcdf4');
	
ncwrite(out, 'PREC', vdata);
ncwrite(out, 'Times', times);
ncwrite(out, 'lat', lats);
ncwrite(out, 'lon', lons);
exit;

