#!/bin/csh

#
# Metafile Script : ngmsvr_meta_svr
#
# Log :
# D.W.Plummer/NCEP   2/97   Add log header
# D.W.Plummer/NCEP   3/97   Adjustment to Convective Outlook TITLE placement
# D.W.Plummer/NCEP   3/97   Changed SCALE=-2 to SCALE=0, also
#                           removed all references to quo(x,20.) and sub(x,10.)
#

set type=tdl
set mdl=ngmsvr
set dt=${1}
set cycle=${2}
set hostpid=`hostname`_${$}

setenv SCRP_DIR	$NADATA/scripts
setenv BIN_DIR	$NADATA/bin
setenv GRDS_DIR	$MODEL/"$type"
setenv META_DIR	$NTRANS_META/${type}
setenv NAOPX    $NADATA/scripts/$type/${mdl}/${mdl}_meta_out_${hostpid}
setenv NAOP		$NADATA/scripts/$type/${mdl}/${mdl}_meta_out

set device="nc | Nmeta.${hostpid}"

set grid=${GRDS_DIR}/${mdl}_${dt}${cycle}

if ( ${cycle} == 00 )  then
	set time1=F36
	set t1=24
	set tt1=ptstl${t1}
	set ct1=cpsvg${t1}
	set bt1=BSVR${t1}
	set bst1=BTSTM${t1}
	set time2=F60
	set t2=24
	set tt2=ptstl${t2}
	set ct2=cpsvg${t2}
	set bt2=BSVR${t2}
	set bst2=BTSTM${t2}
else if ( ${cycle} == 12 ) then
	set time1=F24
	set t1=18
	set tt1=ptstl${t1}
	set ct1=cpsvg${t1}
	set bt1=BSVR${t1}
	set bst1=BTSTM${t1}
	set time2=F48
	set t2=24
	set tt2=ptstl${t2}
	set ct2=cpsvg${t2}
	set bt2=BSVR${t2}
	set bst2=BTSTM${t2}
endif

gdplot_nc << EOF  >>$NAOPX
 GDFILE   = $grid
 DEVICE   = $device
 GVECT    = 
 WIND     = 

 MAP      = 31//2
 PROJ     = STR/90;-105;0/nm
 GAREA    = 23;-120.49;44;-61
 CLEAR    = yes
 PANEL    = 0
 TEXT     = 1/21//hw
 SCALE    = 0
 LATLON   = 0
 HILO     =
 HLSYM    =
 CLRBAR   = 1/h/lc/0.5;0.93/0.8;0.01/1
 CONTUR   = 5/3
 SKIP     = 0

 LINE     = 32//2/0      !5//2/1
 CINT     = 5/10/100     !5/5/5
 FINT     = 10;20;30;40;50;60;70;80
 FLINE    = 0;18-25
 CTYPE    = c/f          !c
 GDATTIM  = f8;f14;f20;f26

 GLEVEL   = 15200:4600
 GVCORD   = hght
 GFUNC    = sm9s(catsh06)  !sm9s(catsh06)
 TITLE    = 5/0/^ NGM MOS 6-h CAT INDEX (>=MDT-SVR/HIGH)|~ CAT MDT-SVR/HIGH
run

 GFUNC    = sm9s(catmh06)  !sm9s(catmh06)
 TITLE    = 5/0/^ NGM MOS 6-h CAT INDEX (>=LGT-MDT/HIGH)|~ CAT LGT-MDT/HIGH
run

 GLEVEL   = 4600:0
 GFUNC    = sm9s(catsl06)  !sm9s(catsl06)
 TITLE    = 5/0/^ NGM MOS 6-h CAT INDEX (>=MDT-SVR/LOW)|~ CAT MDT-SVR/LOW
run

 GFUNC    = sm9s(catml06)  !sm9s(catml06)
 TITLE    = 5/0/^ NGM MOS 6-h CAT INDEX (>=LGT-MDT/LOW)|~ CAT LGT-MDT/LOW
run

 LINE     = 32//2/0      !5//2/1
 CINT     = 5/10/100     !5/5/5
 FINT     = 10;20;30;40;50;60;70;80;90
 FLINE    = 0;18-26
 CTYPE    = c/f          !c
 FINT     = 10;20;30;40;50;60;70;80;90
 FLINE    = 0;18-26
 CONTUR   = 2/9          !0/7
 GFUNC    = sm5s(iceh06)   !sm5s(iceh06)
 GLEVEL   = 15200:4600
 GVCORD   = hght
TITLE    = 31/0/~ NGM MOS 6-h ICING INDEX (>=LGT-MDT/HIGH)|~ICE LGT-MDT/HIGH
run

 GFUNC    = sm5s(icel06)   !sm5s(icel06)
 GLEVEL   = 4600:0
TITLE    = 31/0/~ NGM MOS 6-h ICING INDEX (>=LGT-MDT/LOW)|~ICE LGT-MDT/LOW
run

 GDATTIM  = ${time1}

 GLEVEL   = 0
 GVCORD   = NONE

 LINE     = 32//1/0     
 CINT     = 10/10/100  
 CTYPE    = c/f       
 GFUNC    = ${tt1}
TITLE=5/0/~^ NGM MOS ${t1}HR THUNDERSTORM PROBABILITY |^ ${t1}HR TSTORM PROB
run

 LINE     = 32//1/0      !5//2/1
 CINT     = 10/10/100    !2/2/8
 CTYPE    = c/f          !c
 GFUNC    = ${ct1}!${ct1}
TITLE=5/0/~^ NGM MOS ${t1}HR CNDTNL SVR TSTM PROB|^ ${t1}HR CND SVR TSTM PROB
run

 GFUNC    = MUL(MUL(${ct1},${tt1}),0.01)//X ! X
TITLE=5/0/~^ NGM MOS ${t1}HR UNCNDTNL SVR TSTM PROB|^ ${t1}HR UNCND SVRTSTM PRB
run

 GDATTIM  = ${time2}

 LINE     = 32//1/0     
 CINT     = 10/10/100  
 CTYPE    = c/f       
 GFUNC    = ${tt2}
TITLE=5/0/~^ NGM MOS ${t2}HR THUNDERSTORM PROBABILITY |^ ${t2}HR TSTORM PROB
run

 LINE     = 32//1/0      !5//2/1
 CINT     = 10/10/100    !2/2/8
 CTYPE    = c/f          !c
 GFUNC    = ${ct2}!${ct2}
TITLE=5/0/~^ NGM MOS ${t2}HR CNDTNL SVR TSTM PROB|^ ${t2}HR CND SVR TSTM PROB
run

 GFUNC    = MUL(MUL(${ct2},${tt2}),0.01)//X ! X
TITLE=5/0/~^ NGM MOS ${t2}HR UNCNDTNL SVR TSTM PROB|^ ${t2}HR UNCND SVRTSTM PRB
run

exit
EOF

#gdplot_nc << EOF  >>$NAOPX
gdmap << EOF  >>$NAOPX
 GDFILE   = $grid
 DEVICE   = $device
 GVECT    = 
 WIND     = 
 GAREA    = 23;-120.49;44;-61
 SKIP     = 1/1;1
 POSN     = 0
 MARKER   = 0
 LATLON   = 0
 PANEL    = 0
 PROJ     = STR/90;-105;0/
 PROJ     = STR/90;-105;0/nm
 TEXT     = 1/21//hw
 GRDLBL   = 0
 
 GDATTIM  = ${time1}

 CLEAR    = yes
 MAP      = 25//1
 CINT     = 1/0/0
 SCALE    = 0
 GLEVEL   = 0
 GVCORD   = NONE
 GFUNC    = ${bt1}
 COLORS   = 0
 TITLE    = 20/-2/~ NGM MOS CONVECTIVE OUTLOOK (SEVERE LOCAL STORM)|~ ACO SVR
run
 
 CLEAR    = no

 COLORS   = 21
 MAP      = 0
 CINT     = 0/1/1
 TITLE    = 21/-1/* 1=APPROACHING,                              *|
run

 COLORS   = 5
 CINT     = 0/2/2
 MAP      = 0
 TITLE    =  5/-1/*                2=SLIGHT,                    *|
run

 COLORS   = 2
 CINT     = 0/3/3
 TITLE    =  2/-1/*                          3=MODERATE,        *|
run

 COLORS   = 31
 CINT     = 0/4/4
 TITLE    = 31/-1/*                                      4=HIGH *|
run

 CLEAR    = yes

 CINT     = 0/1/1
 MAP      = 25//1
 COLORS   = 5
 GFUNC    = ${bst1}
 TITLE    = 20/0/~ NGM MOS CONVECTIVE OUTLOOK (THUNDERSTORM)|~ ACO TSTM
run

 GDATTIM  = ${time2}

 CLEAR    = yes
 MAP      = 25//1
 CINT     = 0/1/1
 SCALE    = 0
 GLEVEL   = 0
 GVCORD   = NONE
 GFUNC    = ${bt2}
 COLORS   = 0
 TITLE    = 20/-2/~ NGM MOS CONVECTIVE OUTLOOK (SEVERE LOCAL STORM)|~ ACO SVR
run
 
 CLEAR    = no

 COLORS   = 21
 MAP      = 0
 CINT     = 0/1/1
 TITLE    = 21/-1/* 1=APPROACHING,                              *|
run

 COLORS   = 5
 CINT     = 0/2/2
 MAP      = 0
 TITLE    =  5/-1/*                2=SLIGHT,                    *|
run

 COLORS   = 2
 CINT     = 0/3/3
 TITLE    =  2/-1/*                          3=MODERATE,        *|
run

 COLORS   = 31
 CINT     = 0/4/4
 TITLE    = 31/-1/*                                      4=HIGH *|
run

 CLEAR    = yes

 CINT     = 0/1/1
 MAP      = 25//1
 COLORS   = 5
 GFUNC    = ${bst2}
 TITLE    = 20/0/~ NGM MOS CONVECTIVE OUTLOOK (THUNDERSTORM)|~ ACO TSTM
run

exit
EOF

gpend

mv $NAOPX $NAOP

mv Nmeta.${hostpid} $META_DIR/.${type}_${dt}_${cycle}_${mdl}_svr
mv $META_DIR/.${type}_${dt}_${cycle}_${mdl}_svr $META_DIR/${type}_${dt}_${cycle}_${mdl}_svr

$BIN_DIR/NA_notify meta TDL_${mdl}_svr ${dt} ${cycle} 00 X

$BIN_DIR/meta_transfer $type $dt $cycle ${mdl}_svr all &

exit