Merge remote-tracking branch 'origin/release-v4.5.2'
[WRF.git] / var / mri4dvar / nc_increment.ncl
blobf8eb0468a5fee4bba62ca58592be7818f4ed3eeb
1 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
2 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
5 begin
8    filename = "analysis_increments"
10    varnames = (/"psi","chi_u","t_u","rh","ps_u"/)
11    nvar = dimsizes(varnames)
13    setfileoption("bin","ReadByteOrder","BigEndian")
14    dims = fbinrecread(filename,0,6,"integer")   
15    ni=dims(1) ;;+ 1
16    nj=dims(3) ;;+ 1
17    nk=dims(5) ;;+ 1
18    print("ni, nj, nk = "+ni+", "+nj+", "+nk)
20    vv = fbinrecread(filename,1,(/4,nk,nj,ni/),"double")
22    system("/bin/rm -f "+filename+".nc")   ; remove any pre-existing file
23    ncdf = addfile(filename+".nc" ,"c")  ; open output netCDF file
25     ;===================================================================
26     ; make time an UNLIMITED dimension; recommended  for most applications
27     ;===================================================================
28     ;   filedimdef(ncdf,"time",-1,True) 
30    u = new((/nk, nj,ni/),double)
31    v = new((/nk, nj,ni/),double)
32    ;w = new((/nk, nj,ni/),double)
33    ;p = new((/nk, nj,ni/),double)
34    t = new((/nk, nj,ni/),double)
35    q = new((/nk, nj,ni/),double)
36    ;z = new((/nk, nj,ni/),double)
38    u(:,:,:) = vv(0,:,:,:)
39    v(:,:,:) = vv(1,:,:,:)
40    ;w(:,:,:) = vv(2,:,:,:)
41    ;p(:,:,:) = vv(3,:,:,:)
42    t(:,:,:) = vv(2,:,:,:)
43    q(:,:,:) = vv(3,:,:,:)
44    ;z(:,:,:) = vv(6,:,:,:)
45    
47    ncdf->u = u
48    ncdf->v = v
49    ;ncdf->w = w
50    ;ncdf->p = p
51    ncdf->t = t
52    ncdf->q = q
53    ;ncdf->z = z
55 end