;Reading HDF4-SDS files
;*********** Load Libraries ************************************
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" 
;**************************************************************
begin
;***************************************************************
; User Input
;***************************************************************
                                             ; INPUT
   diri    = "./"                            ; input directory
   fili    = "2A12.100702.71931.6.HDF"       ;       file
;   var     = "latentHeat"                   ; desired variable                   

;***************************************************************
; Read hdf 
;***************************************************************

   f      = addfile (diri+fili, "r")

   lat  = f->geolocation(:,:,0)            ; (scan, pixel)
   lon  = f->geolocation(:,:,1)            

   lat@units = "degrees_north"             ; add units
   lon@units = "degrees_east"
   print(lat@hdf_name)

;-------------------------------
data=f->latentHeat(:,:,8)
data@lon2d=lon
data@lat2d=lat
var_name=data@hdf_name
   printVarSummary(data)
;   print(data)                       
;-------------------------------
  ;printMinMax(lat, True)
  ;printMinMax(lon, True)
;-------------------------------
  xwks=gsn_open_wks("ps",fili+var_name)
colors =(/"white","black","royal blue","light sky blue",\
             "powder blue","light sea green","pale green","wheat","brown",\
             "pink"/)
gsn_define_colormap(xwks,colors)
;
;
res=True
;-----------Title-----------
res@tiMainString=fili
res@gsnCenterString=var_name
;---------------------------
;Map resouces------------------
res@mpFillOn = False
res@mpOutlineOn = True
res@mpOutlineBoundarySets = "National"
res@mpGeophysicalLineColor =  "Black" ;Color of Conuntry Outline
res@mpGeophysicalLineThicknessF =  1.5    ;thickness of Country Outline
res@mpMinLonF=50
res@mpMaxLonF=120
res@mpMinLatF=5
res@mpMaxLatF=35
;
;-----------Contour resources----------
res@cnFillOn = True
res@cnMonoFillColor = False
res@cnLevelSelectionMode="ExplicitLevels"    ;
res@cnLevels            =(/0,200,400,600,800,1000,1200,1400,1600,1800/)
;--------resources end------------------
plot=gsn_csm_contour_map_ce(xwks,data,res)
end  

