load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

begin
r = 64

f = addfile("~/WORK3/jiwen/m"+r+"/tk.nc","r")
T = f->tk
f = addfile("~/WORK3/jiwen/m"+r+"/qv.nc","r")
q = f->qv
T = T*(1.+0.608*q)
f = addfile("~/WORK3/jiwen/m"+r+"/p.nc","r")
p = f->p
    
var = pot_temp(p,T,-1,False)
var!1 = "time"
printVarSummary(var)
printMinMax(var,True)
    
fn = "data/thetav.nc"
system("rm -f "+fn)
filout = addfile(fn,"c")
filout->thetav = var
end
