function plt(args)

pl=subwrd(args,1)
if (pl='-h')
  say ' '
  say ' Plots the Basic State of the Cases: Temperature'
  say ' and Static Stability for the Reference Case csvm'
  say ' '
  say ' Usage:'
  say ' plteb [pl] [stlp] [stl1] [stl2]'
  say ' '
  say ' Default: pl = 1 ; stlp = yesi ; stl1=A ; stl2=B'
  say ' '
  say ' Must be runned under grads -p (portrait)'
  say ' '
  say ' args meaning:'
  say ' '
  say ' pl : to stop (=1) or not (!=1) between frames'
  say ' stlp : to put (yes) or not (no) the label A, B at the figures'
  say ' stl1 : label for Temperature : A, B'
  say ' stl2 : label for Static Stability : A, B'
  say ' '
  return
endif
* To stop (pl=1) or not (pl!=1) between screens
if (pl='') ; pl=1 ; endif
* To put (yes) or Not (no) the label A, B, C ... at the figures.
stlp=subwrd(args,2)
if (stlp='') ; stlp='yes' ; endif
* To put label for the figure if equal capital letter: A, B 
* Label for Temperature
stl1=subwrd(args,3)
if (stl1='') ; stl1='A' ; endif
* Label for Static Stability
stl2=subwrd(args,4)
if (stl2='') ; stl1='B' ; endif

rec=chkmdpt()
if (rec!=0)
  return
endif

* Getting Kmax (number of pressure levels) and csvm (reference case)
'run ../../Config/Case_Dates.gs 'MONAN' 1 'ZCAS' 'no
filecsdt='./Case_Dates.dgs'
rec=read(filecsdt)
lrec=sublin(rec,2)
Kmax=subwrd(lrec,1)
csvm=subwrd(lrec,5)
rec=close(filecsdt)
'!rm -f 'filecsdt
if (Kmax < 100)
  _ResVer='L0'Kmax
else
  _ResVer='L'Kmax
endif

say ' '
say ' csvm = 'csvm' Kmax = 'Kmax'  pl = 'pl'  stlp = 'stlp
say ' '

fcg='dir.cfg'
rec=read(fcg)
lrec=sublin(rec,1)
lrec=sublin(rec,2)
diri=subwrd(lrec,1)
rec=read(fcg)
lrec=sublin(rec,2)
_dirfig=subwrd(lrec,1)%'png_'csvm'/'
rec=close(fcg)

filei='Vertical_Standards_'csvm'.'_ResVer'.ctl'

say ' '
say '  diri = 'diri
say ' filei = 'filei
say ' '

'reinit'

dfilei=diri''filei
rec=chkopfl(dfilei)
if (rec!=0)
  return
endif

'open 'dfilei

vrga=210
vrgb=290
xli=10
say ' '
say ' vrga = 'vrga'  vrgb = 'vrgb'  xli = 'xli
say ' '

'set display color white'
'clear'

'set grads off'
'set xlopts 1 8 0.15'
'set ylopts 1 8 0.15'
'set zlog on'
'set ylevs 1000 800 600 500 400 300 200 150 100 70 50 30 20 15 10 7 5 3 2 1 0.5'
'set cthick 8'
'set xlint 'xli
'set vrange 'vrga' 'vrgb
'display t0'

'query gxinfo'
lx=sublin(result,3)
ly=sublin(result,4)
xa=subwrd(lx,4)
xb=subwrd(lx,6)
ya=subwrd(ly,4)
yb=subwrd(ly,6)

'draw title `1Standard Temperature US 1976\`1Case : 'csvm' - 'Kmax' Levels'
'draw xlab `1Temperature (K)'
xs=xa-0.75
ys=0.5*(ya+yb)
'set string 1 c 6 90'
'set strsiz 0.2'
'draw string 'xs' 'ys' `1Pressure (hPa)'

if (stlp='yes')
  xr=xb-0.5
  yr=yb-0.5
  xs=xb-0.25
  ys=yb-0.25
  'set line 0 1 6'
  'draw recf 'xr' 'yr' 'xb' 'yb
  'set line 1 1 6'
  'draw rec 'xr' 'yr' 'xb' 'yb
  'set string 1 c 6 0'
  'set strsiz 0.175'
  'draw string 'xs' 'ys' `1'stl1
endif

figname='Basic_Standard_Temp_'csvm'_'_ResVer'.png'
say ' 'figname
fig=_dirfig''figname
'printim 'fig' png white'

if (pl=1)
  say ' '
  say 'Press <ENTER> for Static Stability'
  pull frame
endif
'clear'

vrga=0.0001
vrgb=10000
xlvs='0.0001 0.001 0.01 0.1 1 10 100 1000 10000'
say ' '
say ' vrga = 'vrga'  vrgb = 'vrgb
say ' xlevs : 'xlvs
say ' '

'clear'
'set grads off'
'set log1d loglog'
'set xlopts 1 8 0.15'
'set ylopts 1 8 0.15'
'set ylevs 1000 800 600 500 400 300 200 150 100 70 50 30 20 15 10 7 5 3 2 1 0.5'
'set cthick 8'

'set vrange 'vrga' 'vrgb
'set xlevs 'xlvs
'set xlab %0.e'
'display gama'

'draw title `1Static Stability Parameter\`1Case : 'csvm' - 'Kmax' Levels'
'draw xlab `3C `1(m/hPa2)'

xs=xa-0.75
ys=0.5*(ya+yb)
'set string 1 c 6 90'
'set strsiz 0.2'
'draw string 'xs' 'ys' `1Pressure (hPa)'

if (stlp='yes')
  xr=xa+0.5
  yr=yb-0.5
  xs=xa+0.25
  ys=yb-0.25
  'set line 0 1 6'
  'draw recf 'xa' 'yr' 'xr' 'yb
  'set line 1 1 6'
  'draw rec 'xa' 'yr' 'xr' 'yb
  'set string 1 c 6 0'
  'set strsiz 0.175'
  'draw string 'xs' 'ys' `1'stl2
endif

figname='Basic_Standard_Gama_'csvm'_'_ResVer'.png'
say ' 'figname
say ' '
fig=_dirfig''figname
'printim 'fig' png white'

return

function chkmdpt()
'query gxinfo'
lm=sublin(result,2)
xb=subwrd(lm,4)
yb=subwrd(lm,6)
rec=0
if (yb < xb)
  say ' '
  say ' Error: must use grads -p (portrait)'
  say ' '
  rec=1
endif
return rec

function chkopfl(file)
res=read(file)
rec=sublin(res,1)
if (rec=0)
   lrec=sublin(res,2)
   dst=subwrd(lrec,1)
   if (dst!='dset') ; rec=1 ; endif
endif
if (rec!=0)
  say ' '
  say ' Error : 'file' does not exist or is not a ctl file'
  say ' '
endif
if (rec=0)
  res=close(file)
endif
return rec
