    PCA_File="pca_"
    EOF_File="eof_"
    Ntime=1116; Yr1=2007; Yr2=2099
    Vrange1=-3; Vrange2=3
   "reinit"

    PCA_File="pca_SCE_rcp45_CNRM-CM5"
    EOF_File="eof_SCE_rcp45_CNRM-CM5"
    Ntime=1116; Yr1=2007; Yr2=2099
    Vrange1=-3; Vrange2=3

    Var.1="pdsi"; Var.2="spi12";Var.3="spe12";
    Mod.1="PC1"; Mod.2="PC2"; Mod.3="PC3"; Mod.4="PC4"; Mod.5="PC5"

    x00=0.5; x01=8.4;  y00=10.5; y01=1.0
    Nvar=3; Nmod=5
    Nrow=Nmod; Ncol=Nvar
    dx=(x01-x00)/Ncol; dy=(y00-y01)/Nrow-0.1

    "sdfopen "PCA_File".nc"
    "reset"; "set display white"; "c"
     irow=0;

   While (irow<Nrow)
      irow=irow+1; icol=0
      if (irow=1); y2=y00-(irow-1)*dy; y1=y2-dy; y11=y1; endif
      if (irow>1); y2=y11-0.1; y1=y2-dy; y11=y1; endif
      "set t "irow
      While (icol<Ncol)
         icol=icol+1
         x1=x00+(icol-1)*dx; x2=x1+dx; x11=x2; 
         if (icol>1); x1=x1+0.01*(icol-1); x2=x1+dx; endif
         "set parea "x1" "x2" "y1" "y2
         "set grads off"; "set gxout grfill"; "set frame on"; "set grid off";
         "set xlab off";"set ylab on";
         if (irow=Nrow); "set xlab on"; endif
          T_clor()
         "d "Var.icol "(t=" irow ")*100" 
         if (irow=Nrow); draw_tit((x1+x2)/2, y01-0.2, Var.icol); endif
      Endwhile
      draw_tit_ver(x00-0.2, (y1+y2)/2, Mod.irow)
   Endwhile
   "set string 1 c 4.0 0"; "cbarn"; "set string 1 c 5.5 0"
   draw_tit(x00+(x01-x00)/2, y00+0.2, " Spatial patterns of drought over SEA")
   "gxprint "PCA_File".pdf pdf"
   "set parea off";
   "c"
   "close 1"

* EOF Timeseries of Drought over SEA:
   mark.1=1; mark.2=2; mark.3=12;
   colo.1=1; colo.2=1; colo.3=1;
   thic.1=5; thic.2=5; thic.3=5;
   styl.1=0; styl.2=0; styl.3=0;

   "sdfopen "EOF_File".nc"
   irow=0; Nplt=Nrow*Nvar
   x1=x00+0.5; x2=x01-0.3
   "set x 1 "Ntime
   iplt=0; dy=(y00-y01)/Nplt-0.065
   While (irow<Nrow)
      irow=irow+1;
      ivar=0
      While (ivar<Nvar)
         ivar=ivar+1; iplt=iplt+1
         if (iplt=1); y2=y00; y1=y2-dy; y11=y1; y12=y2; endif
         if (iplt>1); y2=y11-0.03; y1=y2-dy; y11=y1;y12=y2; endif
         if (ivar=1 & irow>1); y2=y12-0.18 ; y1=y2-dy; y11=y1;y12=y2; endif
         "set parea "x1" "x2" "y1" "y2
         "set string 1 c 5.5 0"; "set strsiz 0.02 0.02"
         "set vrange "Vrange1" "Vrange2;
         "set ylint 3";
         "set xlab off"; "set ylab on";
         if (iplt=Nplt); "set xlab on"; "set xaxis "Yr1" "Yr2; endif
         "set y "irow
         "set gxout linefill";
         "define aa=" Var.ivar
         "define a0=aa-aa"; "set lfcols 2 4"; "set grads off"
         "d "Var.ivar ";a0"
         draw_tit(x00+1.0,y2-0.1, Var.ivar)
         if (ivar=2); draw_tit_ver(x00+0.1,(y1+y2)/2, Mod.irow); endif
      Endwhile
   Endwhile
   draw_tit(x00+(x01-x00)/2, y00+0.2, " Timeseries of EOFs of drought over SEA")
  "gxprint "EOF_File".pdf pdf"
   "set parea off";
   "c"
   "close 1"
   "quit"
*******************************************************
function draw_tit_ver(x, y, title)
  "set string 1 c 5.5 90"; "set strsiz 0.12 0.12"
  "draw string "x" "y" "title
  "set string 1 c 5.5 0"
return
*******************************************************
function draw_tit(x, y, title)
  "set string 1 c 5.5 0"; "set strsiz 0.12 0.12"
  "draw string "x" "y" "title
return
*******************************************************
function T_clor()
*levels = " -0.6 -0.4 -0.2 -0.1 0 0.1 0.2 0.4 0.6 "

levels = " -1 -0.8 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.8 1"
*levels = " -10 -8 -6 -5 -4 -3 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 3 4 5 6 8 10"
*levels = " -10 -8 -6 -5 -4 -3 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 3 4 5 6 8 10"
*levels = " -30 -20 -10 -8 -6 -5 -4 -3 -2 -1.5 -1 0 1 1.5 2 3 4 5 6 8 10 20 30"
"run My_Color.gs -gxout grfill -kind red->white-(0)->white->green -levs" levels
"set grads off"
return
*******************************************************
function P_clor()
levels = " -100 -70 -50 -30 -20 -10 -5 0 5 10 20 30 50 70 100 "
"run My_Color.gs -gxout grfill -kind red->yellow-(0)->aqua->blue -levs" levels
"set grads off"
return
*******************************************************
function Line_pl(mark,colo,thick,styl)
"set gxout line"
"set cmark "mark
"set ccolor "colo
"set cthick "thick
"set cstyle "styl
return
********************************************
function Mark_leg(colo,type,x,y,size)
"set line "colo
"draw mark "type" "x" "y" "size
return
********************************************

