#!/bin/bash -l

conda activate e3sm_unified_latest 

datadir="b.e11.B1850CN.T31_g37.001/atm"
outdir="ts"
if [ ! -d "$outdir" ];then 
  mkdir $outdir
fi 

for year in `seq 1 500`;do
  ystr=`printf "%04d" $year`	
  files=`echo $datadir/*.${ystr}-*.nc`
  for var in TS U V T Q TS SOLIN PHIS;do 
      outfile="${outdir}/${var}_${ystr}01_${ystr}12.nc"
      ncrcat -d time,0, -v ${var} ${files[@]} ${outfile}
  done 
done 
