
;; Empty NCL template
;; run code in recipes, use it carefully

;;DIAG_NORCPM; RUNTHESECODES: print("    no ncl code run here")

begin
    dfn = "ens_TREFHT_trend.nc" ;; usually T2m or Tsfc 
    vn  = "TREFHT"
    dfn2= "ens_sst_trend.nc" ;; overlay, usually be sst
    vn2 = "sst"
    ofig= "TREFHT_ens_trend_ANN"
    
    isoverlay = isfilepresent(dfn2) 

    df = addfile(dfn,"r")
    var = df->$vn$(0,:,:)
    var = var*120 ;; monthly trend to annual trend

    if (isoverlay) then
        df2 = addfile(dfn2,"r")
        var2 = df2->$vn2$(0,:,:)
        var2 = var2*120 ;; monthly trend to annual trend
        ;; for micom
        gridf = addfile("/cluster/shared/noresm/inputdata/ocn/micom/gx1v6/20101119/grid.nc","r")
        var2@lat2d = gridf->plat
        var2@lon2d = gridf->plon
    end if
    res = True
        res@cnFillOn = True
        res@cnLinesOn = False
        res@cnFillMode = "CellFill"
        res@mpCenterLonF = 210.
        res@cnLevelSelectionMode = "ExplicitLevels"
        res@cnLevels = (/-.3,.3,.5,.7,.9/)
        res@cnFillColors = (/(/225,239,223,255/), (/255,255,255,255/), (/248,246,226,255/), (/244,218,140,255/), (/241,192,45,255/), (/168,129,32,255/)/)
        res@cnFillColors := res@cnFillColors / 255.
        
        res@gsnLeftString = "TroPac_DA Decadal trend t2m"
        res@gsnRightString = "ANN"

        res@gsnFrame = False
        res@gsnDraw  = False

    res2 = True
        res2@cnFillOn = True
        res2@cnLinesOn = False
        res2@cnFillMode = "CellFill"
        res2@cnLevelSelectionMode = "ExplicitLevels"
        res2@cnLevels = (/-.2,-.1,.1,.2,.3,.4/)
        res2@cnFillColors = (/(/189,202,232,155/), (/207,217,239,155/), (/255,255,255,0/), (/245,219,223,155/), (/244,198,200,155/), (/246,175,179,155/), (/247,155,157,155/)/)
        res2@cnFillColors := res2@cnFillColors / 255.
        res2@gsnDraw = False
        res2@gsnFrame = False
        res2@gsnAddCyclic = True
        res2@gsnLeftString = ""
        res2@gsnRightString = ""
        res2@lbTopMarginF = 0.4
        res2@lbLabelFontHeightF = 0.01

    if(isoverlay)then
        res@lbOrientation = "vertical"
        res@lbLabelFontHeightF = 0.01
        res@lbRightMarginF =  0.50
        res@lbLeftMarginF = -0.10
    end if

        
    wks = gsn_open_wks("ps",ofig)
    plot = gsn_csm_contour_map(wks,var,res)

    if(isoverlay)then
        plot2 = gsn_csm_contour(wks,var2,res2)
        overlay(plot,plot2)
    end if

    draw(plot)
    frame(wks)
end


