#var="TXx TXn TNx TNn RX1day RX5day SDII DTR"
#var="TXx TXn TNx TNn Rx1day Rx5day SDII DTR"
exp="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18"
#exp="07"
var="T2M"
# T2m: chinh sua bien trong file.gs = tas
for ivar in ${var} ; do 
  for e in ${exp} ; do
    rm KQ.txt
    ln -sf ../../MOD_links/${ivar}/cmv_mn_${ivar}_searci_${e}.1989_2007.nc ./AAAAAA.nc
    cat interpol.mn.gs | sed s/NXTVAR/${ivar}/g > interpol_run.gs
    grads -lbc interpol_run.gs
    ./del_line.sh KQ.txt
#
cp write_ECE_mn.f90 tmp.f90
    sed 's/ECE/'${ivar}'/g' -i tmp.f90
    sed 's/INDEX/'${e}'/g' -i tmp.f90
    pgf90 tmp.f90
    ./a.out
    rm tmp.f90
#
mkdir ../${ivar}
mv KQ/* ../${ivar}/
#    mv OUTPUT.txt OUT_REG_${ivar}_BASE_dd.txt
 done
done
