#!/bin/csh -f
foreach jj (crossxy.????.000.???.nc)
rm temp*.nc
set exp=$jj:r:e
set ih=$jj:r:r:r:e
rm crossxy.$ih.$exp.nc
foreach ii (crossxy.$ih.*.$exp.nc)
set idy = $ii:r:r:e
ncks -O -v uxy crossxy.$ih.$idy.${exp}.nc tempu.$ih.$idy.nc
ncks -O -v vxy crossxy.$ih.$idy.${exp}.nc tempv.$ih.$idy.nc
ncks -O -v wxy,thlxy,thvxy,qtxy,qlxy,qrxy,buoyxy crossxy.$ih.$idy.$exp.nc temp.$ih.$idy.nc
ncpdq -O -a yt,time,xm tempu.$ih.$idy.nc tempu.$ih.$idy.nc # Make y record dimension
ncpdq -O -a ym,time,xt tempv.$ih.$idy.nc tempv.$ih.$idy.nc # Make y record dimension
ncpdq -O -a yt,time,xt temp.$ih.$idy.nc temp.$ih.$idy.nc # Make y record dimension
end
ncrcat -O tempu.$ih.???.nc tempuxy.$ih.nc       # Concatenate along y
ncrcat -O tempv.$ih.???.nc tempvxy.$ih.nc       # Concatenate along y
ncrcat -O temp.$ih.???.nc tempxy.$ih.nc         # Concatenate along y
ncpdq -O -a time,yt,xm tempuxy.$ih.nc tempuxy.$ih.nc # Revert to time as record dimension
ncpdq -O -a time,ym,xt tempvxy.$ih.nc tempvxy.$ih.nc # Revert to time as record dimension
ncpdq -O -a time,yt,xt tempxy.$ih.nc crossxy.$ih.$exp.nc # Revert to time as record dimension
ncks -A tempuxy.$ih.nc crossxy.$ih.$exp.nc
ncks -A tempvxy.$ih.nc crossxy.$ih.$exp.nc
end
rm temp*.nc
