; ---------------------------------------------------

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 "~/NIFA/NCL_6.5.0_functions/simple_legend_ndc.ncl"

; ---------------------------------------------------

Begin

  ; ***********************************************
  ; 1 - READ IN MC2 FILE
  ; ***********************************************

  print("1 - Read in file")

  diri  = "~/NIFA/MC2/subset_100_M/rcp_45/fs/CCSM4/VTYPE_3_GROUPED/"
  MC2_f = addfile(diri + "rcp_45_fs_CCSM4_VTYPE_3_grouped_lat_zone_0_2015-2099_time_series.nc","r")

  ; ***********************************************
  ; 2 - EXTRACT VARIABLES
  ; ***********************************************

  print("2 - Extract variables")

  data_00 = MC2_f->G_timeseries
  year    = MC2_f->year
  units   = "%"

  ; ***********************************************
  ; 3 - CREATE MATRIX PLOT
  ; ***********************************************

  print("3 - Create Plot Matrix")

  diro = "~/NIFA/MC2/subset_100_M/time_series/VTYPE/3_groups_HOV_TEST/"
  filo = "rcp_45_fs_CCSM4_VTYPE_percentage_G_HOV_TEST"

  wks_type          = "png"  ; plot file type
  wks_type@wkWidth  = 3500   ; width dimension
  wks_type@wkHeight = 3500   ; height dimension

  wks = gsn_open_wks(wks_type, diro + filo)

  ; ***********************************************
  ; create color plot
  ; ***********************************************

  res               = True         ; plot mods desired
  res@cnFillOn      = True         ; turn on color fill
  res@cnFillPalette = "WhiteGreen" ; set color map

  res@tiMainString   = "Entire Great Plains"    ; title
  res@gsnLeftString  = "C3 and C4 Grassland"    ; title
  res@gsnRightString = "% land cover" 		   ; title

  res@cnLevelSelectionMode  = "ManualLevels"	   ; manual contour levels
  res@cnMinLevelValF        = 0                 ; min level
  res@cnMaxLevelValF        = 100               ; max level
  res@cnLevelSpacingF       = 10                ; contour level spacing
  res@trYMinF               = 2015              ; min  y axis value
  res@trYMaxF               = 2100              ; max  y axis value
  res@trXMinF               = -105              ; min  y axis value
  res@trXMaxF               = -95               ; max  x axis value
  
  plot = gsn_csm_hov(wks,data_00,res) 

end