#!/bin/csh

# hard wired settings begin

set cycle_cluster_data = 00
set cycle_cluster_meta = 00

set testn=0
set testb=0
set testd=0
set testm=0
set testl=0
set testv=0
set testx=0
set testo=0
set tests=0

# test variables may be reset by environment variables RLW_ENS_META_TESTl

# testn ==> NADATA
# testn=0 as run operationally (NADATA=HOME)
# testn=1 set to /export-1/sgi74/data/wd20rw/nadata
# testn=2 as set externally

# testb ==> bin library
# testb=0 as run operationally ($NADATA/bin)
# testb=1 hardwired to ~wd20rw/bin

# testd ==> data source
# testd=0 as run operationally (NADATA)
# testd=1 hardwired to operational data archive
# testd=2 hardwired to dd data archive
# testd=3 set to /export-1/sgi74/data/wd20rw/nadata/model/grid/ens
# testd=4 hardwired to current directory
# testd=5 as set externally

# testm ==> metafile location
# testm=0 as run operationally (NADATA)
# testm=1 hardwired to operational metafile archive
# testm=2 hardwired to dd metafile archive
# testm=3 set to /export/sgi80/wd20rw/meta
# testm=4 hardwired to current directory
# testm=5 as set externally

# testl ==> length of metafile
# testl=0 as run operationally (full length)
# testl=1 short run with fewer frames

# testv ==> output
# testv=0 as run operationally (mostly silent)
# testv=1 verbose

# testx ==> run the plots?
# testx=0 as run operationally (run GEMPAK)
# testx=1 run the setup only

# testo ==> run operational notify?
# testo=0 as run operationally (move metafile and notify)
# testo=1 test (do not move metafile or notify)
# testo=2 test (do not move metafile or notify, add suffix _t)
# testo=3 alternate (do not move metafile or notify, add suffix _u)
# testo=4 verifying (do not move metafile or notify, add suffix _v)
# testo=5 global (do not move metafile or notify, add suffix _g)
# testo=6 experimental (do not move metafile or notify, add suffix _x)
# testo=7 ECMWF (do not move metafile or notify, add suffix _e)
# testo=8 skill (do not move metafile or notify, add suffix _s)

if ( $?RLW_ENS_META_TESTN == '1' ) then
	set testn = $RLW_ENS_META_TESTN
endif
if ( $?RLW_ENS_META_TESTB == '1' ) then
	set testb = $RLW_ENS_META_TESTB
endif
if ( $?RLW_ENS_META_TESTD == '1' ) then
	set testd = $RLW_ENS_META_TESTD
endif
if ( $?RLW_ENS_META_TESTM == '1' ) then
	set testm = $RLW_ENS_META_TESTM
endif
if ( $?RLW_ENS_META_TESTL == '1' ) then
	set testl = $RLW_ENS_META_TESTL
endif
if ( $?RLW_ENS_META_TESTV == '1' ) then
	set testv = $RLW_ENS_META_TESTV
endif
if ( $?RLW_ENS_META_TESTX == '1' ) then
	set testx = $RLW_ENS_META_TESTX
endif
if ( $?RLW_ENS_META_TESTO == '1' ) then
	set testo = $RLW_ENS_META_TESTO
endif

# hard wired settings end

if ( $#argv < 2 ) then
	echo $0 requires yymmdd hh
	exit
endif
set yymmdd = $1
set cycle_in = $2

if ( $testn == '0' ) then
	set NADATA=$HOME
endif
if ( $testn == '1' ) then
	set NADATA=/export-1/sgi74/data/wd20rw/nadata
endif

set mdl="ens"

if ( $testb == '0' ) then
	set BIN_DIR=$NADATA/bin
endif
if ( $testb == '1' ) then
	set BIN_DIR=~wd20rw/bin
endif

if ( $testd == '0' ) then
	set GRDS_DIR=$NADATA/model/grid/$mdl
endif
if ( $testd == '1' ) then
	set GRDS_DIR=~nadataop/model/grid/$mdl 
endif
if ( $testd == '2' ) then
	set GRDS_DIR=/export-2/sgi80/data/model/$mdl 
endif
if ( $testd == '3' ) then
	set GRDS_DIR=/export-1/sgi74/data/wd20rw/nadata/model/grid/$mdl 
endif
if ( $testd == '4' ) then
	set GRDS_DIR=`pwd`
endif

if ( $testm == '0' ) then
	set META_DIR=$NADATA/meta/model/$mdl
endif
if ( $testm == '1' ) then
	set META_DIR=~nadataop/meta/model/$mdl 
endif
if ( $testm == '2' ) then
	set META_DIR=/export/sgi51/meta/$mdl 
endif
if ( $testm == '3' ) then
	set META_DIR=/export/sgi80/wd20rw/meta 
endif
if ( $testm == '4' ) then
	set META_DIR=`pwd`
endif

if ( $testo == '0' ) then
	set suffix=
endif
if ( $testo == '1' ) then
	set suffix=
endif
if ( $testo == '2' ) then
	set suffix=_t
endif
if ( $testo == '3' ) then
	set suffix=_u
endif
if ( $testo == '4' ) then
	set suffix=_v
endif
if ( $testo == '5' ) then
	set suffix=_g
endif
if ( $testo == '6' ) then
	set suffix=_x
endif
if ( $testo == '7' ) then
	set suffix=_e
endif
if ( $testo == '8' ) then
	set suffix=_s
endif

@ day = $yymmdd % 100
@ yymm = $yymmdd / 100
@ month = $yymm % 100
@ year = $yymm / 100
@ y4 = $year % 4

if ( ( $month < 1 ) || ( $month > 12 ) ) then
	echo out of range:  month = $month
	exit
endif

if ( $y4 == 0 ) then
	set lomm = ( 31 29 31 30 31 30 31 31 30 31 30 31 )
	set lomp = ( 31 31 29 31 30 31 30 31 31 30 31 30 )
else
	set lomm = ( 31 28 31 30 31 30 31 31 30 31 30 31 )
	set lomp = ( 31 31 28 31 30 31 30 31 31 30 31 30 )
endif

@ lm = $lomm[$month]
@ lp = $lomp[$month]

if ( ( $day < 1 ) || ( $day > $lm ) ) then
	echo out of range:  day = $day
	exit
endif

if ( $day == 1 ) then
	@ yday = $lp
	if ( $month == 1 ) then
		@ ymonth = 12
		if ( $year == 0 ) then
			@ yyear = 99
		else
			@ yyear = $year - 1
		endif
	else
		@ ymonth = $month - 1
		@ yyear = $year
	endif
else
	@ yday = $day - 1
	@ ymonth = $month
	@ yyear = $year
endif
	
@ yesterdayx = ( ( ( 100 + $yyear ) * 100  + $ymonth ) * 100 + $yday ) 
set yesterday = `echo $yesterdayx | cut -c2-7`

set run = 0
set part = 0

set swlat = -5.0
set swlon = -135.0
set nelat = 50.0
set nelon = -5.0

set swlat = -4.0
set swlon = -134.0
set nelat = 39.0
set nelon = 3.0

if ( $cycle_in == '00' ) then
	set avn_cycle = 12
	set avn_yymmdd = $yesterday
	set mrf_cycle = 00
	set mrf_yymmdd = $yymmdd 
	set cycle = 00
	set run = mrf
	set part = cycle
endif
if ( $cycle_in == '01' ) then
	set avn_cycle = 12
	set avn_yymmdd = $yesterday
	set mrf_cycle = 00
	set mrf_yymmdd = $yymmdd 
	set cycle = 00
	set run = clu
	set part = cluster
endif
if ( $cycle_in == '12' ) then
	set avn_cycle = 12
	set avn_yymmdd = $yymmdd
	set mrf_cycle = 00
	set mrf_yymmdd = $yymmdd 
	set cycle = 12
	set run = avn
	set part = cycle
endif
if ( $run == '0' ) then
	echo cycle_in $cycle_in not valid
	exit
endif

# set avn_yymmdd=`/bin/ls -l $GRDS_DIR/avn.???????? | tail -1 | awk -F. '{print $NF}' | cut -c1-6`
# set avn_cycle=12
# set mrf_yymmdd=`/bin/ls -l $GRDS_DIR/mrf.???????? | tail -1 | awk -F. '{print $NF}' | cut -c1-6`
# set mrf_cycle=00

if ( $testv > '0' ) then
	echo "test n="$testn "b="$testb "d="$testd "m="$testm "l="$testl "v="$testv "x="$testx "o="$testo
	echo "    yymmdd" = $yymmdd     " cycle_in" = $cycle_in  
	echo " yesterday" = $yesterday  "    cycle" = $cycle
	echo "avn_yymmdd" = $avn_yymmdd "avn_cycle" = $avn_cycle " part" = $part
	echo "mrf_yymmdd" = $mrf_yymmdd "mrf_cycle" = $mrf_cycle "  run" = $run
	echo "cycle_cluster_data" = $cycle_cluster_data "  cycle_cluster_meta" = $cycle_cluster_meta
	echo META_DIR = $META_DIR
	echo GRDS_DIR = $GRDS_DIR
	echo BIN_DIR  = $BIN_DIR
endif

if ( -w $META_DIR ) then
else
	echo no write access to META_DIR=$META_DIR 
	exit
endif

if ( -x $GRDS_DIR ) then
else
	echo no search access to GRDS_DIR=$GRDS_DIR 
	exit
endif

if ( -x $BIN_DIR ) then
else
	echo no search access to BIN_DIR=$BIN_DIR 
	exit
endif

if ( $testx > '0' ) then
	exit
endif

if ( $part == cycle ) then

	# if ( ${avn_yymmdd}${avn_cycle} > ${mrf_yymmdd}${mrf_cycle} ) then
	if ( $run == 'avn' ) then
		set cycle = ${avn_cycle}
	#	set out_name = "/tmp/ens.${avn_yymmdd}${avn_cycle}.out"
		set out_name = "/tmp/ens.cycle.t${avn_cycle}.out"
		set modl_order_set = 'mrf avn'
		if ( $testl == '1' ) then
			set mrf_fhr_set = '012 036 228 252'
		else
			set mrf_fhr_set = '012 036 060 084 108 132 156 180 204 228 252'
		endif
		set lmrf = -3
		set lcnt = -4
		set lmn1 = -5
		set lavn = -1
		set lan1 = -2
	endif
	if ( $run == mrf ) then
		set cycle = ${mrf_cycle}
	#	set out_name = "/tmp/ens.${mrf_yymmdd}${mrf_cycle}.out"
		set out_name = "/tmp/ens.cycle.t${mrf_cycle}.out"
		set modl_order_set = 'avn mrf'
		if ( $testl == '1' ) then
			set mrf_fhr_set = '012 036 228 252'
		else
			set mrf_fhr_set = '012 036 060 084 108 132 156 180 204 228 252'
		endif
		set lmrf = -1
		set lcnt = -2
		set lmn1 = -3
		set lavn = -4
		set lan1 = -5
	endif

	set cmrfb = 5
	set ccntb = 17
	set cmp1b = 2 
	set cmn1b = 2
	set cmp2b = 2
	set cmn2b = 2
	set cmp3b = 2
	set cmn3b = 2
	set cmp4b = 2
	set cmn4b = 2
	set cmp5b = 2
	set cmn5b = 2
	set cavnb = 21
	set cap1b = 25
	set can1b = 25
	set cap2b = 25 
	set can2b = 25 

	set cmrfd = 18
	set ccntd = 15
	set cmp1d = 14
	set cmn1d = 14
	set cmp2d = 14
	set cmn2d = 14
	set cmp3d = 14
	set cmn3d = 14
	set cmp4d = 14
	set cmn4d = 14
	set cmp5d = 14
	set cmn5d = 14
	set cavnd = 23
	set cap1d = 4
	set can1d = 4
	set cap2d = 4 
	set can2d = 4 

	set cmrfp = 5
	set ccntp = 10
	set cmp1p = 12 
	set cmn1p = 12
	set cmp2p = 12
	set cmn2p = 12
	set cmp3p = 12
	set cmn3p = 12
	set cmp4p = 12
	set cmn4p = 12
	set cmp5p = 12
	set cmn5p = 12
	set cavnp = 21
	set cap1p = 27
	set can1p = 27
	set cap2p = 27 
	set can2p = 27 

	rm -f $out_name

	echo avn_yymmdd = ${avn_yymmdd}  avn_cycle = ${avn_cycle}
	echo mrf_yymmdd = ${mrf_yymmdd}  mrf_cycle = ${mrf_cycle}

	set gp_input = gp_input_${mrf_yymmdd}_${avn_yymmdd}_${cycle}

	rm -f $gp_input

	foreach mrf_fhr ( $mrf_fhr_set )

		if ( ${avn_yymmdd} < ${mrf_yymmdd} )  then
			set avn_fhr=`expr ${mrf_fhr} + 12`
		else
			set avn_fhr=`expr ${mrf_fhr} - 12`
		endif 
		if ( ${avn_fhr} < 10 ) then
			set avn_fhr = 0${avn_fhr}
		endif
		if ( ${avn_fhr} < 100 ) then 
			set avn_fhr = 0${avn_fhr}
		endif

		set gfunls_set = " "

                if ( ( $month <=  4 ) || ( $month >= 10 ) ) then
			set gfunls_set = "$gfunls_set hght;500;5220"
		endif 
		set         gfunls_set = "$gfunls_set hght;500;5400"
		set         gfunls_set = "$gfunls_set hght;500;5520"
		set         gfunls_set = "$gfunls_set hght;500;5640"
		set         gfunls_set = "$gfunls_set hght;500;5760"
		set         gfunls_set = "$gfunls_set hght;500;5820"
		if ( ( $month >=  5 ) && ( $month <=  9 ) ) then 
			set gfunls_set = "$gfunls_set hght;500;5880"
		endif

		set         gfunls_set = "$gfunls_set thkn;500:1000;5400"

                if ( ( $month <=  4 ) || ( $month >= 10 ) ) then
			set gfunls_set = "$gfunls_set temp;850;0"
		endif
                if ( ( $month >=  5 ) && ( $month <=  9 ) ) then
			set gfunls_set = "$gfunls_set temp;850;15"
		endif

#		set gfunls_set = "$gfunls_set mslphl;0;1016"
#		set gfunls_set = "$gfunls_set mslphl;0;992"
#		set gfunls_set = "$gfunls_set mslph;0;1000"
#		set gfunls_set = "$gfunls_set mslpl;0;1032"
#		set gfunls_set = "$gfunls_set mslphl;0;0"
#		set gfunls_set = "$gfunls_set mslph;0;0"
#		set gfunls_set = "$gfunls_set mslpl;0;0"

		if ( ( $month <= 4 ) || ( $month >=  9 ) ) then
			set gfunls_set = "$gfunls_set mslp;0;992"
		endif
		set         gfunls_set = "$gfunls_set mslp;0;1000"
		if ( ( $month >= 5 ) && ( $month <=  8 ) ) then
			set gfunls_set = "$gfunls_set mslp;0;1008"
		endif
		set gfunls_set = "$gfunls_set mslphl;0;0"
		if ( ( $month >= 3 ) || ( $month <= 11 ) ) then
			set gfunls_set = "$gfunls_set mslp;0;1024"
		endif
		set         gfunls_set = "$gfunls_set mslp;0;1032"
		if ( ( $month <= 2 ) && ( $month >= 12 ) ) then
			set gfunls_set = "$gfunls_set mslp;0;1040"
		endif

		if      ( $month ==  1 ) then
			set gfunls_set = "$gfunls_set winds;250;50"
			set gfunls_set = "$gfunls_set winds;850;15"
		else if ( $month ==  2 ) then
			set gfunls_set = "$gfunls_set winds;250;50"
			set gfunls_set = "$gfunls_set winds;850;15"
		else if ( $month ==  3 ) then
			set gfunls_set = "$gfunls_set winds;250;45"
			set gfunls_set = "$gfunls_set winds;850;15"
		else if ( $month ==  4 ) then
			set gfunls_set = "$gfunls_set winds;250;40"
			set gfunls_set = "$gfunls_set winds;850;12"
		else if ( $month ==  5 ) then
			set gfunls_set = "$gfunls_set winds;250;35"
			set gfunls_set = "$gfunls_set winds;850;12"
		else if ( $month ==  6 ) then
			set gfunls_set = "$gfunls_set winds;250;35"
			set gfunls_set = "$gfunls_set winds;850;12"
		else if ( $month ==  7 ) then
			set gfunls_set = "$gfunls_set winds;250;35"
			set gfunls_set = "$gfunls_set winds;850;12"
		else if ( $month ==  8 ) then
			set gfunls_set = "$gfunls_set winds;250;35"
			set gfunls_set = "$gfunls_set winds;850;12"
		else if ( $month ==  9 ) then
			set gfunls_set = "$gfunls_set winds;250;40"
			set gfunls_set = "$gfunls_set winds;850;12"
		else if ( $month == 10 ) then
			set gfunls_set = "$gfunls_set winds;250;45"
			set gfunls_set = "$gfunls_set winds;850;15"
		else if ( $month == 11 ) then
			set gfunls_set = "$gfunls_set winds;250;50"
			set gfunls_set = "$gfunls_set winds;850;15"
		else if ( $month == 12 ) then
			set gfunls_set = "$gfunls_set winds;250;50"
			set gfunls_set = "$gfunls_set winds;850;15"
		endif

 		set         gfunls_set = "$gfunls_set rh;700;90"

#		alternate contours

		if ( $testo == '3' ) then

			set gfunls_set = " "

			set gfunls_set = "$gfunls_set hght;500;4860"
			set gfunls_set = "$gfunls_set hght;500;5040"
			set gfunls_set = "$gfunls_set hght;500;5220"

			set gfunls_set = "$gfunls_set hght;500;5880"
			set gfunls_set = "$gfunls_set hght;500;5910"
			set gfunls_set = "$gfunls_set hght;500;5940"

			set gfunls_set = "$gfunls_set temp;850;0"
			set gfunls_set = "$gfunls_set temp;850;15"

			set gfunls_set = "$gfunls_set mslp;0;992"
			set gfunls_set = "$gfunls_set mslp;0;1008"
			set gfunls_set = "$gfunls_set mslp;0;1024"
			set gfunls_set = "$gfunls_set mslp;0;1040"

			set gfunls_set = "$gfunls_set winds;250;80"
			set gfunls_set = "$gfunls_set winds;250;70"
			set gfunls_set = "$gfunls_set winds;250;60"
			set gfunls_set = "$gfunls_set winds;250;55"
			set gfunls_set = "$gfunls_set winds;250;50"
			set gfunls_set = "$gfunls_set winds;250;45"
			set gfunls_set = "$gfunls_set winds;250;40"
			set gfunls_set = "$gfunls_set winds;250;35"
			set gfunls_set = "$gfunls_set winds;250;30"

			set gfunls_set = "$gfunls_set winds;850;25"
			set gfunls_set = "$gfunls_set winds;850;20"
			set gfunls_set = "$gfunls_set winds;850;15"
			set gfunls_set = "$gfunls_set winds;850;12"
			set gfunls_set = "$gfunls_set winds;850;10"
			set gfunls_set = "$gfunls_set winds;850;8"

 			set gfunls_set = "$gfunls_set rh;700;70"
		endif

#		set gfunls_set = "$gfunls_set fr;850;2"
#		set gfunls_set = "$gfunls_set fr;850;5"
#		set gfunls_set = "$gfunls_set fr;850;10"
#		set gfunls_set = "$gfunls_set frgl;850;0"
#		set gfunls_set = "$gfunls_set frgl;850;997"
#		set gfunls_set = "$gfunls_set frg;850;997"
#		set gfunls_set = "$gfunls_set frl;850;997"
#		set gfunls_set = "$gfunls_set wd;250;030"
#		set gfunls_set = "$gfunls_set wd;250;090"
#		set gfunls_set = "$gfunls_set wd;250;150"
#		set gfunls_set = "$gfunls_set wd;250;210"
#		set gfunls_set = "$gfunls_set wd;250;270"
#		set gfunls_set = "$gfunls_set wd;250;330"
#		set gfunls_set = "$gfunls_set wd;850;030"
#		set gfunls_set = "$gfunls_set wd;850;090"
#		set gfunls_set = "$gfunls_set wd;850;150"
#		set gfunls_set = "$gfunls_set wd;850;210"
#		set gfunls_set = "$gfunls_set wd;850;270"
#		set gfunls_set = "$gfunls_set wd;850;330"
	
		if ( $testv > '0' ) then
			echo gfunls_set = $gfunls_set
		endif
	
		foreach gfunls ( $gfunls_set )
	
			set gfunl = `echo $gfunls | cut -d\; -f1`
			set glev  = `echo $gfunls | cut -d\; -f2`
			set cint  = `echo $gfunls | cut -d\; -f3`
			set cintt = $cint
			set cintl = $cint
			set cinth = $cint
	
			set gvcord = PRES
			set contur = 0
			set hlsym = 0
			set clear = yes
			set panel = 0  

			set wprime = 4
			set wline = 2

			set cmrf = $cmrfb
			set ccnt = $ccntb
			set cmp1 = $cmp1b
			set cmn1 = $cmn1b
			set cmp2 = $cmp2b
			set cmn2 = $cmn2b
			set cmp3 = $cmp3b
			set cmn3 = $cmn3b
			set cmp4 = $cmp4b
			set cmn4 = $cmn4b
			set cmp5 = $cmp5b
			set cmn5 = $cmn5b
			set cavn = $cavnb
			set cap1 = $cap1b
			set can1 = $can1b
			set cap2 = $cap2b
			set can2 = $can2b

			set cmrft = $cmrfb
			set ccntt = $ccntb
			set cmp1t = $cmp1b
			set cmn1t = $cmn1b
			set cmp2t = $cmp2b
			set cmn2t = $cmn2b
			set cmp3t = $cmp3b
			set cmn3t = $cmn3b
			set cmp4t = $cmp4b
			set cmn4t = $cmn4b
			set cmp5t = $cmp5b
			set cmn5t = $cmn5b
			set cavnt = $cavnb
			set cap1t = $cap1b
			set can1t = $can1b
			set cap2t = $cap2b
			set can2t = $can2b

			set hlmrf = 0
			set hlcnt = 0
			set hlmp1 = 0
			set hlmn1 = 0
			set hlmp2 = 0 
			set hlmn2 = 0
			set hlmp3 = 0
			set hlmn3 = 0
			set hlmp4 = 0
			set hlmn4 = 0
			set hlmp5 = 0
			set hlmn5 = 0
			set hlavn = 0
			set hlap1 = 0
			set hlan1 = 0
			set hlap2 = 0 
			set hlan2 = 0 

			set hlr = 3
			set hln = 90
			set hlt = 'msl pres ctr'

			if ( $gfunl == hght ) then
				set gfun = hght
				set title = 'height'
				set unit = m
			endif

			if ( $gfunl == winds ) then
				set gfun = 'mag(vecr[urel,vrel])'
				set title = 'wind speed'
				set unit = 'm/s'
				set contur = 2/0
			endif

			if ( $gfunl == ws ) then
				set gfun = 'mag(vecr[urel,vrel])'
				set title = 'wind speed'
				set unit = 'm/s'
			endif

			if ( $gfunl == thkn ) then
				set gfun = 'ldf(hght)'
				set title = 'thickness'
				set unit = m
			endif

			if ( $gfunl == temp ) then
				set gfun = 'temp'
				set title = 'temperature'
				set unit = C
				set contur = 2/0
			endif

			if ( $gfunl == mslp) then
				set gfun = 'pmsl'
				set title = 'msl pressure'
				set unit = mb
				set contur = 2/0
				set gvcord = NONE
			endif

			if ( $gfunl == mslphl190) then
				set hlr = 1
				set hln = 90
				set gfunl = mslphl
				set hlt = 'mslpc190'
			endif

			if ( $gfunl == mslphl290) then
				set hlr = 2
				set hln = 90
				set gfunl = mslphl
				set hlt = 'mslpc290'
			endif

			if ( $gfunl == mslphl390) then
				set hlr = 3
				set hln = 90
				set gfunl = mslphl
				set hlt = 'mslpc390'
			endif

			if ( $gfunl == mslphl160) then
				set hlr = 1
				set hln = 60
				set gfunl = mslphl
				set hlt = 'mslpc160'
			endif

			if ( $gfunl == mslphl260) then
				set hlr = 2
				set hln = 60
				set gfunl = mslphl
				set hlt = 'mslpc260'
			endif

			if ( $gfunl == mslphl360) then
				set hlr = 3
				set hln = 60
				set gfunl = mslphl
				set hlt = 'mslpc360'
			endif

			if ( $gfunl == mslphl130) then
				set hlr = 1
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc130'
			endif

			if ( $gfunl == mslphl230) then
				set hlr = 2
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc230'
			endif

			if ( $gfunl == mslphl330) then
				set hlr = 3
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc330'
			endif

			if ( $gfunl == mslphl630) then
				set hlr = 6
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc630'
			endif

			if ( $gfunl == mslphl1230) then
				set hlr = 12 
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc1230'
			endif

			if ( $gfunl == mslphl2430) then
				set hlr = 24 
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc2430'
			endif

			if ( $gfunl == mslphl4830) then
				set hlr = 48 
				set hln = 30 
				set gfunl = mslphl
				set hlt = 'mslpc4830'
			endif

			if ( $gfunl == mslphl9630) then
				set hlr = 96 
				set hln = 30
				set gfunl = mslphl
				set hlt = 'mslpc9630'
			endif

			if ( $gfunl == mslphl320) then
				set hlr = 3
				set hln = 20
				set gfunl = mslphl
				set hlt = 'mslpc320'
			endif

			if ( $gfunl == mslphl310) then
				set hlr = 3
				set hln = 10
				set gfunl = mslphl
				set hlt = 'mslpc310'
			endif

			if ( $gfunl == mslphl610) then
				set hlr = 6
				set hln = 10
				set gfunl = mslphl
				set hlt = 'mslpc610'
			endif

			if ( $gfunl == mslphl1210) then
				set hlr = 12 
				set hln = 10
				set gfunl = mslphl
				set hlt = 'mslpc1210'
			endif

			if ( $gfunl == mslphl2410) then
				set hlr = 24 
				set hln = 10
				set gfunl = mslphl
				set hlt = 'mslpc2410'
			endif

			if ( $gfunl == mslphl4810) then
				set hlr = 48 
				set hln =10 
				set gfunl = mslphl
				set hlt = 'mslpc4810'
			endif

			if ( $gfunl == mslphl9610) then
				set hlr = 96 
				set hln = 10
				set gfunl = mslphl
				set hlt = 'mslpc9610'
			endif

			if ( $gfunl == mslphl305) then
				set hlr = 3
				set hln = 5
				set gfunl = mslphl
				set hlt = 'mslpc305'
			endif

			if ( $gfunl == mslphl605) then
				set hlr = 3
				set hln = 5
				set gfunl = mslphl
				set hlt = 'mslpc605'
			endif

			if ( $gfunl == mslphl1205) then
				set hlr = 12 
				set hln = 5
				set gfunl = mslphl
				set hlt = 'mslpc1205'
			endif

			if ( $gfunl == mslphl2405) then
				set hlr = 24 
				set hln = 5
				set gfunl = mslphl
				set hlt = 'mslpc2405'
			endif

			if ( $gfunl == mslphl4805) then
				set hlr = 48 
				set hln = 5
				set gfunl = mslphl
				set hlt = 'mslpc4805'
			endif

			if ( $gfunl == mslphl9605) then
				set hlr = 96 
				set hln = 5
				set gfunl = mslphl
				set hlt = 'mslpc9605'
			endif

			if ( $gfunl == mslphl) then
				set gfun = 'pmsl'
				set title = "$hlt" 
				set cintt =
				set unit = 
				set gvcord = NONE
				set hlmrf = "$cmrfp;$cmrfp/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlcnt = "$ccntp;$ccntp/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp1 = "$cmp1p;$cmp1p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn1 = "$cmn1p;$cmn1p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp2 = "$cmp2p;$cmp2p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn2 = "$cmn2p;$cmn2p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp3 = "$cmp3p;$cmp3p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn3 = "$cmn3p;$cmn3p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp4 = "$cmp4p;$cmp4p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn4 = "$cmn4p;$cmn4p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp5 = "$cmp5p;$cmp5p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn5 = "$cmn5p;$cmn5p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlavn = "$cavnp;$cavnp/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlap1 = "$cap1p;$cap1p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlan1 = "$can1p;$can1p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlap2 = "$cap2p;$cap2p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlan2 = "$can2p;$can2p/H;L/1017-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlsym = "1;1/2/2;2//hw;hw"
				set cmrft = $cmrfp
				set ccntt = $ccntp
				set cmp1t = $cmp1p
				set cmn1t = $cmn1p
				set cmp2t = $cmp2p
				set cmn2t = $cmn2p
				set cmp3t = $cmp3p
				set cmn3t = $cmn3p
				set cmp4t = $cmp4p
				set cmn4t = $cmn4p
				set cmp5t = $cmp5p
				set cmn5t = $cmn5p
				set cavnt = $cavnp
				set cap1t = $cap1p
				set can1t = $can1p
				set cap2t = $cap2p
				set can2t = $can2p
			endif

			if ( $gfunl == mslph) then
				set gfun = 'pmsl'
				set title = 'mslp hi ctr'
				set cintt =
				set unit = 
				set gvcord = NONE
				set hlmrf = "$cmrfb;$cmrfb/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlcnt = "$ccntb;$ccntb/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp1 = "$cmp1b;$cmp1b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn1 = "$cmn1b;$cmn1b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp2 = "$cmp2b;$cmp2b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn2 = "$cmn2b;$cmn2b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp3 = "$cmp3b;$cmp3b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn3 = "$cmn3b;$cmn3b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp4 = "$cmp4b;$cmp4b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn4 = "$cmn4b;$cmn4b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp5 = "$cmp5b;$cmp5b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn5 = "$cmn5b;$cmn5b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlavn = "$cavnb;$cavnb/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlap1 = "$cap1b;$cap1b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlan1 = "$can1b;$can1b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlap2 = "$cap2b;$cap2b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlan2 = "$can2b;$can2b/H;L/1017-2000;0-1/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlsym = "1;1/2/2;2//hw;hw"
				set cmrf = $cmrfd
				set ccnt = $ccntd
				set cmp1 = $cmp1d
				set cmn1 = $cmn1d
				set cmp2 = $cmp2d
				set cmn2 = $cmn2d
				set cmp3 = $cmp3d
				set cmn3 = $cmn3d
				set cmp4 = $cmp4d
				set cmn4 = $cmn4d
				set cmp5 = $cmp5d
				set cmn5 = $cmn5d
				set cavn = $cavnd
				set cap1 = $cap1d
				set can1 = $can1d
				set cap2 = $cap2d
				set can2 = $can2d
			endif

			if ( $gfunl == mslpl) then
				set gfun = 'pmsl'
				set title = 'mslp lo ctr'
				set cintt =
				set unit = 
				set gvcord = NONE
				set hlmrf = "$cmrfb;$cmrfb/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlcnt = "$ccntb;$ccntb/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp1 = "$cmp1b;$cmp1b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn1 = "$cmn1b;$cmn1b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp2 = "$cmp2b;$cmp2b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn2 = "$cmn2b;$cmn2b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp3 = "$cmp3b;$cmp3b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn3 = "$cmn3b;$cmn3b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp4 = "$cmp4b;$cmp4b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn4 = "$cmn4b;$cmn4b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmp5 = "$cmp5b;$cmp5b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlmn5 = "$cmn5b;$cmn5b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlavn = "$cavnb;$cavnb/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlap1 = "$cap1b;$cap1b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlan1 = "$can1b;$can1b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlap2 = "$cap2b;$cap2b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlan2 = "$can2b;$can2b/H;L/1917-2000;0-1015/$hlr;$hlr/$hln;$hln/yes;yes"
				set hlsym = "1;1/2/2;2//hw;hw"
				set cmrf = $cmrfd
				set ccnt = $ccntd
				set cmp1 = $cmp1d
				set cmn1 = $cmn1d
				set cmp2 = $cmp2d
				set cmn2 = $cmn2d
				set cmp3 = $cmp3d
				set cmn3 = $cmn3d
				set cmp4 = $cmp4d
				set cmn4 = $cmn4d
				set cmp5 = $cmp5d
				set cmn5 = $cmn5d
				set cavn = $cavnd
				set cap1 = $cap1d
				set can1 = $can1d
				set cap2 = $cap2d
				set can2 = $can2d
			endif

			if ( $gfunl == rh ) then
				set gfun = relh
				set title = 'rel humidity'
				set unit = pct
				set contur = 2/0
				set wprime = 2
				set wline = 1
			endif

			if ( $gfunl == wd ) then
				set gfun = 'dirr(vecr[urel,vrel])'
				set title = 'wind direct'
				set unit = 'deg' 
			endif

			if ( $gfunl == u ) then
				set gfun = 'un(vecr[urel,vrel])'
				set title = 'u wind'
				set unit = 'm/s' 
			endif

			if ( $gfunl == v ) then
				set gfun = 'vn(vecr[urel,vrel])'
				set title = 'v wind'
				set unit = 'm/s' 
			endif

			if ( $gfunl == ur ) then
				set gfun = 'urel'
				set title = 'u wind'
				set unit = 'm/s' 
			endif

			if ( $gfunl == vr ) then
				set gfun = 'vrel'
				set title = 'v wind'
				set unit = 'm/s' 
			endif

			if ( $gfunl == def ) then
				set gfun = 'def(vecr[urel,vrel])'
				set title = 'deformation'
				set unit = '/s' 
			endif

			if ( $gfunl == str ) then
				set gfun = 'str(vecr[urel,vrel])'
				set title = 'stretch'
				set unit = '/s' 
			endif

			if ( $gfunl == shr ) then
				set gfun = 'shr(vecr[urel,vrel])'
				set title = 'shear'
				set unit = '/s' 
			endif

			if ( $gfunl == vor ) then
				set gfun = 'vor(vecr[urel,vrel])'
				set title = 'rel vort'
				set unit = '/s' 
			endif

			if ( $gfunl == avor ) then
				set gfun = 'avor(vecr[urel,vrel])'
				set title = 'abs vort'
				set unit = '/s' 
			endif

			if ( $gfunl == div ) then
				set gfun = 'div(vecr[urel,vrel])'
				set title = 'divergence'
				set unit = '/s' 
			endif

			if ( $gfunl == wsw ) then
				set gfun = 'mul(sub(dirr(vecr[urel,vrel]),225),sqrt(sub(mag(vecr[urel,vrel]),25)))'
				set title = 'jet wind dir'
				set unit = '225deg'
			endif   

			if ( $gfunl == ww ) then
				set gfun = 'mul(sub(dirr(vecr[urel,vrel]),270),sqrt(sub(mag(vecr[urel,vrel]),25)))'
				set title = 'jet wind dir'
				set unit = ' 270deg' 
			endif

			if ( $gfunl == wnw ) then
				set gfun = 'mul(sub(dirr(vecr[urel,vrel]),315),sqrt(sub(mag(vecr[urel,vrel]),25)))'
				set title = 'jet wind dir'
				set unit = ' 315deg' 
			endif

			if ( $gfunl == wa ) then
				set gfun = 'cros(vecr[urel,vrel],sm5v(vecr[urel,vrel]))'
				set title = 'wind x smoothed wind'
				set unit = 'axis' 
			endif

			if ( $gfunl == fr ) then
				set gfun = 'frnt(thta,vecr[urel,vrel])'
				set title = 'frontogenesis'
				set unit = 'K/100km/3h' 
			endif

			if ( $gfunl == frgl) then
				set gfun = 'frnt(thta,vecr[urel,vrel])'
				set title = 'frt g l ctr'
				set unit = 'K/100km/3h' 
				set gvcord = PRES
				set hlmrf = "$cmrfb;$cmrfb/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlcnt = "$ccntb;$ccntb/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmp1 = "$cmp1b;$cmp1b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmn1 = "$cmn1b;$cmn1b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmp2 = "$cmp2b;$cmp2b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmn2 = "$cmn2b;$cmn2b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmp3 = "$cmp3b;$cmp3b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmn3 = "$cmn3b;$cmn3b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmp4 = "$cmp4b;$cmp4b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmn4 = "$cmn4b;$cmn4b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmp5 = "$cmp5b;$cmp5b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlmn5 = "$cmn5b;$cmn5b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlavn = "$cavnb;$cavnb/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlap1 = "$cap1b;$cap1b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlan1 = "$can1b;$can1b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlap2 = "$cap2b;$cap2b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlan2 = "$can2b;$can2b/+;-/0-1000;-1000-0/3;3/97;97/yes;yes"
				set hlsym = "1;1/2/2;2//hw;hw"
				set cmrf = $cmrfd
				set ccnt = $ccntd
				set cmp1 = $cmp1d
				set cmn1 = $cmn1d
				set cmp2 = $cmp2d
				set cmn2 = $cmn2d
				set cmp3 = $cmp3d
				set cmn3 = $cmn3d
				set cmp4 = $cmp4d
				set cmn4 = $cmn4d
				set cmp5 = $cmp5d
				set cmn5 = $cmn5d
				set cavn = $cavnd
				set cap1 = $cap1d
				set can1 = $can1d
				set cap2 = $cap2d
				set can2 = $can2d
			endif

			if ( $gfunl == frg) then
				set gfun = 'frnt(thta,vecr[urel,vrel])'
				set title = 'frtgen ctr'
				set unit = 'K/100km/3h' 
				set gvcord = PRES
				set hlmrf = "$cmrfb;$cmrfb/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlcnt = "$ccntb;$ccntb/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmp1 = "$cmp1b;$cmp1b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmn1 = "$cmn1b;$cmn1b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmp2 = "$cmp2b;$cmp2b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmn2 = "$cmn2b;$cmn2b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmp3 = "$cmp3b;$cmp3b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmn3 = "$cmn3b;$cmn3b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmp4 = "$cmp4b;$cmp4b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmn4 = "$cmn4b;$cmn4b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmp5 = "$cmp5b;$cmp5b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlmn5 = "$cmn5b;$cmn5b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlavn = "$cavnb;$cavnb/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlap1 = "$cap1b;$cap1b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlan1 = "$can1b;$can1b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlap2 = "$cap2b;$cap2b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlan2 = "$can2b;$can2b/+;-/0-1000;9998-9999/3;3/97;97/yes;yes"
				set hlsym = "1;1/2/2;2//hw;hw"
				set cmrf = $cmrfd
				set ccnt = $ccntd
				set cmp1 = $cmp1d
				set cmn1 = $cmn1d
				set cmp2 = $cmp2d
				set cmn2 = $cmn2d
				set cmp3 = $cmp3d
				set cmn3 = $cmn3d
				set cmp4 = $cmp4d
				set cmn4 = $cmn4d
				set cmp5 = $cmp5d
				set cmn5 = $cmn5d
				set cavn = $cavnd
				set cap1 = $cap1d
				set can1 = $can1d
				set cap2 = $cap2d
				set can2 = $can2d
			endif

			if ( $gfunl == frl) then
				set gfun = 'frnt(thta,vecr[urel,vrel])'
				set title = 'frtlys ctr'
				set unit = 'K/100km/3h' 
				set gvcord = PRES
				set hlmrf = "$cmrfb;$cmrfb/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlcnt = "$ccntb;$ccntb/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmp1 = "$cmp1b;$cmp1b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmn1 = "$cmn1b;$cmn1b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmp2 = "$cmp2b;$cmp2b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmn2 = "$cmn2b;$cmn2b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmp3 = "$cmp3b;$cmp3b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmn3 = "$cmn3b;$cmn3b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmp4 = "$cmp4b;$cmp4b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmn4 = "$cmn4b;$cmn4b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmp5 = "$cmp5b;$cmp5b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlmn5 = "$cmn5b;$cmn5b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlavn = "$cavnb;$cavnb/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlap1 = "$cap1b;$cap1b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlan1 = "$can1b;$can1b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlap2 = "$cap2b;$cap2b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlan2 = "$can2b;$can2b/+;-/9995-9996;-1000-0/3;3/97;97/yes;yes"
				set hlsym = "1;1/2/2;2//hw;hw"
				set cmrf = $cmrfd
				set ccnt = $ccntd
				set cmp1 = $cmp1d
				set cmn1 = $cmn1d
				set cmp2 = $cmp2d
				set cmn2 = $cmn2d
				set cmp3 = $cmp3d
				set cmn3 = $cmn3d
				set cmp4 = $cmp4d
				set cmn4 = $cmn4d
				set cmp5 = $cmp5d
				set cmn5 = $cmn5d
				set cavn = $cavnd
				set cap1 = $cap1d
				set can1 = $can1d
				set cap2 = $cap2d
				set can2 = $can2d
			endif

			if ( $testv > '0' ) then
				echo `date` $yymmdd $cycle_in $mrf_fhr $avn_fhr gdcntr $glev $gfunl ${cintt}$unit
			endif

			if ( $cycle == 00 ) then

				cat <<EOF >>${gp_input}
dev=nc
gvcord=${gvcord}
contur=${contur}
hlsym=${hlsym}
panel=${panel}
cint=${cint}/${cintl}/${cinth}
PROJ=   str/90;-95;0/0;5;0;0
GAREA=  -6;-135;39;5
GAREA=  ${swlat};${swlon};${nelat};${nelon}
map=1
lat=29
text=1/21//hw

glev=$glev
gfun=${gfun}

clear=${clear}

line=${cmrf}/1/${wprime}/0
hilo=${hlmrf}
title=${cmp1t}/${lmn1}/^ @ $title ${cintt}${unit} MRF ptbn |^ @ $title ${cintt}${unit}
gdatt=${mrf_yymmdd}/0000F${mrf_fhr}
	gdf=$GRDS_DIR/mrf.${mrf_yymmdd}00
l
r

clear=no
map=0
lat=0
EOF

				else

					cat <<EOF >>${gp_input}
dev=nc
gvcord=${gvcord}
contur=${contur}
hlsym=${hlsym}
panel=${panel}
cint=${cint}/${cintl}/${cinth}
PROJ=   str/90;-95;0/0;5;0;0
GAREA=  -6;-135;39;5
GAREA=  ${swlat};${swlon};${nelat};${nelon}
map=1
lat=29
text=1/21//hw

glev=$glev
gfun=${gfun}

clear=${clear}

line=${cavn}/1/${wprime}/0
hilo=${hlavn}
title=${cap1t}/${lan1}/^ @ $title ${cintt}${unit} AVN ptbn |^ @ $title ${cintt}${unit}
gdatt=${avn_yymmdd}/1200F${avn_fhr}
gdf=$GRDS_DIR/avn.${avn_yymmdd}12
l
r

clear=no
map=0
lat=0
EOF

			endif

			foreach modl ( $modl_order_set )

				if ( $modl == avn ) then

					cat <<EOF >>${gp_input}

line=${can1}/1/${wline}/0
hilo=${hlan1}
title=${can1t}/${lan1}/^ @ $title ${cintt}${unit} AVN ptbn
gdatt=${avn_yymmdd}/1200F${avn_fhr}
gdf=$GRDS_DIR/avn1.${avn_yymmdd}12
r

line=${can2}/1/${wline}/0
hilo=${hlan2}
gdatt=${avn_yymmdd}/1200F${avn_fhr}
gdf=$GRDS_DIR/avn2.${avn_yymmdd}12
title=0
r

line=${cap1}/1/${wline}/0
hilo=${hlap1}
gdatt=${avn_yymmdd}/1200F${avn_fhr}
gdf=$GRDS_DIR/avp1.${avn_yymmdd}12
r

line=${cap2}/1/${wline}/0
hilo=${hlap2}
gdatt=${avn_yymmdd}/1200F${avn_fhr}
gdf=$GRDS_DIR/avp2.${avn_yymmdd}12
r

line=${cavn}/1/${wline}/0
hilo=${hlavn}
title=${cavnt}/${lavn}/^ @ $title ${cintt}${unit} AVN T126
gdatt=${avn_yymmdd}/1200F${avn_fhr}
gdf=$GRDS_DIR/avn.${avn_yymmdd}12
r

EOF

				else

					cat <<EOF >>${gp_input}

line=${cmn1}/1/${wline}/0
hilo=${hlmn1}
title=${cmn1t}/${lmn1}/^ @ $title ${cintt}${unit} MRF ptbn
gdatt=${mrf_yymmdd}/0000F${mrf_fhr}
gdf=$GRDS_DIR/n1.${mrf_yymmdd}00
l
r

title=0
line=${cmn2}/1/${wline}/0
hilo=${hlmn2}
gdf=$GRDS_DIR/n2.${mrf_yymmdd}00
r

line=${cmn3}/1/${wline}/0
hilo=${hlmn3}
gdf=$GRDS_DIR/n3.${mrf_yymmdd}00
r

line=${cmn4}/1/${wline}/0
hilo=${hlmn4}
gdf=$GRDS_DIR/n4.${mrf_yymmdd}00
r

line=${cmn5}/1/${wline}/0
hilo=${hlmn5}
gdf=$GRDS_DIR/n5.${mrf_yymmdd}00
r

line=${cmp1}/1/${wline}/0
hilo=${hlmp1}
gdf=$GRDS_DIR/p1.${mrf_yymmdd}00
r

line=${cmp2}/1/${wline}/0
hilo=${hlmp2}
gdf=$GRDS_DIR/p2.${mrf_yymmdd}00
r

line=${cmp3}/1/${wline}/0
hilo=${hlmp3}
gdf=$GRDS_DIR/p3.${mrf_yymmdd}00
r

line=${cmp4}/1/${wline}/0
hilo=${hlmp4}
gdf=$GRDS_DIR/p4.${mrf_yymmdd}00
r

line=${cmp5}/1/${wline}/0
hilo=${hlmp5}
gdf=$GRDS_DIR/p5.${mrf_yymmdd}00
r

line=${ccnt}/1/${wline}/0
hilo=${hlcnt}
title=${ccntt}/${lcnt}/^ @ $title ${cintt}${unit} MRF  T62
gdatt=${mrf_yymmdd}/0000F${mrf_fhr}
gdf=$GRDS_DIR/cnt.${mrf_yymmdd}00
r

line=${cmrf}/1/${wline}/0
hilo=${hlmrf}
title=${cmrft}/${lmrf}/^ @ $title ${cintt}${unit} MRF T126
gdatt=${mrf_yymmdd}/0000F${mrf_fhr}
gdf=$GRDS_DIR/mrf.${mrf_yymmdd}00
r

EOF

				endif

			end

			cat <<EOF >>${gp_input}
ex
EOF

			#gdcntr << EOF  >>/dev/null
			#gdcntr << EOF
			gdcntr <${gp_input}  >>$out_name

			rm -f ${gp_input}

		end

	end

	if ( $testv > '0' ) echo gpend

	gpend

	if ( $testv > '0' ) echo move metafile

	mv Nmeta ${META_DIR}/."$mdl"_"$mrf_yymmdd"_"$cycle""$suffix"
	mv ${META_DIR}/."$mdl"_"$mrf_yymmdd"_"$cycle""$suffix" ${META_DIR}/"$mdl"_"$mrf_yymmdd"_"$cycle""$suffix"

	if ( $testo == '0' ) then

		$BIN_DIR/NA_notify meta ENSEMBLE ${mrf_yymmdd} ${cycle} 00 X

		$BIN_DIR/meta_transfer $mdl $mrf_yymmdd $cycle none all &

	endif

	if ( $testv > '0' ) echo done

endif

if ( $part == cluster ) then

	set out_name=/tmp/ens.cluster.t${mrf_cycle}.out
	rm -f $out_name

		foreach mrf_fhr ( 84  108  132 )

	if ( $testv > '0' ) then
		echo `date` $yymmdd $cycle_in gdplot for ${mrf_yymmdd} ${mrf_fhr}
	endif

	set cch=5
	set can=13
	set caz=18
	set cap=25
	set crbf7b='26;27;21;20;17;16;13'
	set crbr7b='13;16;17;20;21;27;26'
	set crbf5b='27;21;20;17;13'
	set crbr5b='13;17;20;21;27'
	set c1red='0;14'
	set c2red='0;14;15'
	set c3red='0;14;15;2'
	set c4red='0;14;15;16;2'
	set c1ora='0;16'
	set c2ora='0;16;17'
	set c3ora='0;16;17;9'
	set c4ora='0;16;17;9;10'
	set c1yel='0;8'
	set c2yel='0;8;18'
	set c3yel='0;8;18;19'
	set c4yel='0;8;18;19;20'
	set c1grn='0;23'
	set c2grn='0;23;22'
	set c3grn='0;23;22;3'
	set c4grn='0;23;22;3;21'
	set c1blu='0;24'
	set c2blu='0;24;4'
	set c3blu='0;24;4;25'
	set c4blu='0;24;4;25;26'
	set c1vio='0;30'
	set c3vio='0;30;29'
	set c3vio='0;30;29;28'
	set c4vio='0;30;29;28;7'
	set c6blured='25;4;24;0;14;15;2'
	set c6redblu='2;15;14;0;24;4;25'
	set c6bluredx='24;25;4;0;15;2;14'
	set c6redblux='14;2;15;0;4;25;24'
	set c2blured='24;0;14'
	set c2redblu='14;0;24'
	set c2yr='0;8;14'
	set c3yor='0;8;16;14'
	set c4yorp='0;8;16;14;30'
	set c4rygb='0;14;8;23;24'

	# read variables from the info file
	#
	set infofile = $GRDS_DIR/info.${mrf_yymmdd}${cycle_cluster_data}
	# cat $infofile | head -19 | sed 's/  */ /g' 
	# cat $infofile | head -19  
	# head -1 $infofile | tail -1
	set cfound = false
	foreach i ( 1 2 3 4 5 6 )
		set fh     = `grep MEMBERS $infofile | head -$i | tail -1 | sed 's/  */ /g' | cut -d\  -f4`
		# echo fh   = $fh
		set date   = `grep MEMBERS $infofile | head -$i | tail -1 | sed 's/  */ /g' | cut -d\  -f3`
		# echo date = $date
		set lev    = `grep MEMBERS $infofile | head -$i | tail -1 | sed 's/  */ /g' | cut -d\  -f6`
		# echo lev  = $lev
		if ( $fh == $mrf_fhr ) then
			set cfound = true
			set smrf    = `grep 'MRF        1'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo smrf   = $smrf
			set st62    = `grep 'T62        2'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62   = $st62
			set st62p1  = `grep 'T62P1      3'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62p1 = $st62p1
			set st62n1  = `grep 'T62N1      4'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62n1 = $st62n1
			set st62p2  = `grep 'T62P2      5'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62p2 = $st62p2
			set st62n2  = `grep 'T62N2      6'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62n2 = $st62n2
			set st62p3  = `grep 'T62P3      7'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62p3 = $st62p3
			set st62n3  = `grep 'T62N3      8'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62n3 = $st62n3
			set st62p4  = `grep 'T62P4      9'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62p4 = $st62p4
			set st62n4  = `grep 'T62N4     10'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62n4 = $st62n4
			set st62p5  = `grep 'T62P5     11'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62p5 = $st62p5
			set st62n5  = `grep 'T62N5     12'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo st62n5 = $st62n5
			set savn    = `grep 'AVN       13'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo savn   = $savn
			set savp1   = `grep 'AVP1      14'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo savp1  = $savp1
			set savn1   = `grep 'AVN1      15'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo savn1  = $savn1
			set savp2   = `grep 'AVP2      16'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo savp2  = $savp2
			set savn2   = `grep 'AVN2      17'  $infofile | head -$i | tail -1 | sed 's/  */ /g' `
			# echo savn2  = $savn2
			foreach j ( 1 2 3 4 5 6 )
				@ k = $j + 2
				@ count = 0
				if ( `echo $smrf | cut -d\  -f$k ` == "1" ) then
					set name =  M
					@ count = $count + 1
				else
					set name =  m
				endif
				if ( `echo $st62 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}C"
					@ count = $count + 1
				else
					set name = "${name}c"
				endif
				if ( `echo $st62p1 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $st62n1 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( `echo $st62p2 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $st62n2 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( `echo $st62p3 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $st62n3 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( `echo $st62p4 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $st62n4 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( `echo $st62p5 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $st62n5 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( `echo $savn | cut -d\  -f$k ` == "1" ) then
					set name = "${name} A"
					@ count = $count + 1
				else
					set name = "${name} a"
				endif
				if ( `echo $savp1 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $savn1 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( `echo $savp2 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}P"
					@ count = $count + 1
				else
					set name = "${name}p"
				endif
				if ( `echo $savn2 | cut -d\  -f$k ` == "1" ) then
					set name = "${name}N"
					@ count = $count + 1
				else
					set name = "${name}n"
				endif
				if ( $lev == "500" ) then
					if ( $j == "1" ) then
						set c1n500 = "$name" 
						set c1c500 = $count
					else
						if ( $j == "2" ) then
							set c2n500 = "$name"
							set c2c500 = $count
						else
							if ( $j == "3" ) then
								set c3n500 = "$name" 
								set c3c500 = $count
							else
								if ( $j == "4" ) then
									set c4n500 = "$name" 
									set c4c500 = $count
								else
									if ( $j == "5" ) then
										set c5n500 = "$name"
										set c5c500 = $count
									else
										if ( $j == "6" ) then
											set c6n500 = "$name"
											set c6c500 = $count
										endif
									endif
								endif
							endif
						endif
					endif
				else
					if ( $j == "1" ) then
						set c1n1000 = "$name" 
						set c1c1000 = $count
					else
						if ( $j == "2" ) then
							set c2n1000 = "$name"
							set c2c1000 = $count
						else
							if ( $j == "3" ) then
								set c3n1000 = "$name" 
								set c3c1000 = $count
							else
								if ( $j == "4" ) then
									set c4n1000 = "$name" 
									set c4c1000 = $count
								else
									if ( $j == "5" ) then
										set c5n1000 = "$name"
										set c5c1000 = $count
									else
										if ( $j == "6" ) then
											set c6n1000 = "$name"
											set c6c1000 = $count
										endif
									endif
								endif
							endif
						endif
					endif
				endif
				# echo name = $name
			end
		endif
	end
	if ( $testv > "0" ) then
		echo
		echo mrf_fhr = $mrf_fhr
		echo
		echo c1n500 = $c1n500
		echo c2n500 = $c2n500
		echo c3n500 = $c3n500
		echo c4n500 = $c4n500
		echo c5n500 = $c5n500
		echo c6n500 = $c6n500
		echo
		echo c1n1000 = $c1n1000
		echo c2n1000 = $c2n1000
		echo c3n1000 = $c3n1000
		echo c4n1000 = $c4n1000
		echo c5n1000 = $c5n1000
		echo c6n1000 = $c6n1000
		echo
	endif

	#gdplot << EOF
	#gdplot << EOF  >>/dev/null
	gdplot << EOF  >>$out_name
dev=nc
gvect=
gvcord=PRES
wind=
PROJ=   str/90;-95;0/0;5;0;0
GAREA=  -6;-135;39;5
GAREA=  ${swlat};${swlon};${nelat};${nelon}
map=1
lat=29
text=1/21//hw

gdf=$GRDS_DIR/cluster.${mrf_yymmdd}${cycle_cluster_data}
gdatt=${mrf_yymmdd}/0000F${mrf_fhr} 

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=ENMNHTAN		!ENMNHTAN	!ENMNHTAN	!ENMNHT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ 500mb ENMNHT,ENMNHTAN|~ 500mb ENMNHT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=ENMNHTAN		!ENMNHTAN	!ENMNHTAN	!ENMNHT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ 1000mb ENMNHT,ENMNHTAN|~ 1000mb ENMNHT,AN!
r

clear=yes

scale=0
glev=500:1000		!500:1000	!500:1000	!500:1000
gfun=ldf(ENMNHTAN)	!ldf(ENMNHTAN)	!ldf(ENMNHTAN)	!ldf(ENMNHT)
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ 1000-500mb ENMN THKN,THKNAN|~ 1000-500mb ENMNTHKN,AN!
r

clear=yes

ctype=c/f

scale=0
glev=500
gfun=HTsp

cint=4;8;15;30;60;120;240	
line=$crbf7b/1/2/1
title=5/-1/~ 500mb ENSEMBLE SPREAD|~ 500mb ENSEMBLE SPREAD!
fint     = 30;60;120;240
fline    = $c4rygb
r

clear=yes

ctype=c/f

scale=0
glev=1000
gfun=HTsp

cint=4;8;15;30;60;120;240
line=$crbf7b/1/2/1
title=5/-1/~ 1000mb ENSEMBLE SPREAD|~ 1000mb ENSEMBLE SPREAD!
fint     = 30;60;120;240
fline    = $c4rygb
r

clear=yes

fint=0
fline=0
ctype=c

scale=0
glev=500		!500		!500		!500
gfun=HTAN		!HTAN		!HTAN		!HGHT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ 500mb MRF HGHT,HTAN|~ 500mb MRF HGHT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=HTAN		!HTAN		!HTAN		!HGHT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ 1000mb MRF HGHT,HTAN|~ 1000mb MRF HGHT,AN!
r

clear=yes

scale=0
glev=500:1000		!500:1000	!500:1000	!500:1000
gfun=ldf(HTAN)		!ldf(HTAN)	!ldf(HTAN)	!ldf(HGHT)
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ 1000-500mb MRF THKN,THKNAN|~ 1000-500mb MRF THKN,AN!
r

ex
EOF

	if ( $cfound == true ) then
		gdplot << EOF  >>$out_name
dev=nc
gvect=
gvcord=PRES
wind=
PROJ=   str/90;-95;0/0;5;0;0
GAREA=  -6;-135;39;5
GAREA=  ${swlat};${swlon};${nelat};${nelon}
map=1
lat=29
text=1/21//hw

gdf=$GRDS_DIR/cluster.${mrf_yymmdd}${cycle_cluster_data}
gdatt=${mrf_yymmdd}/0000F${mrf_fhr} 

fint     = 0
fline    = 0
ctype=c

! cluster #1

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=C1HTAN		!C1HTAN		!C1HTAN		!C1HT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C1-500mb HT,HTAN $c1n500 $c1c500|~ C1-500mb HT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=C1HTAN		!C1HTAN		!C1HTAN		!C1HT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C1-1000mb HT,HTAN $c1n1000 $c1c1000|~ C1-1000mb HT,AN!
r

! cluster #2

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=C2HTAN		!C2HTAN		!C2HTAN		!C2HT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C2-500mb HT,HTAN $c2n500 $c2c500|~ C2-500mb HT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=C2HTAN		!C2HTAN		!C2HTAN		!C2HT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C2-1000mb HT,HTAN $c2n1000 $c2c1000|~ C2-1000mb HT,AN!
r

! cluster #3

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=C3HTAN		!C3HTAN		!C3HTAN		!C3HT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C3-500mb HT,HTAN $c3n500 $c3c500|~ C3-500mb HT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=C3HTAN		!C3HTAN		!C3HTAN		!C3HT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C3-1000mb HT,HTAN $c3n1000 $c3c1000|~ C3-1000mb HT,AN!
r

! cluster #4

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=C4HTAN		!C4HTAN		!C4HTAN		!C4HT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C4-500mb HT,HTAN $c4n500 $c4c500|~ C4-500mb HT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=C4HTAN		!C4HTAN		!C4HTAN		!C4HT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C4-1000mb HT,HTAN $c4n1000 $c4c1000|~ C4-1000mb HT,AN!
r

! cluster #5

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=C5HTAN		!C5HTAN		!C5HTAN		!C5HT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C5-500mb HT,HTAN $c5n500 $c5c500|~ C5-500mb HT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=C5HTAN		!C5HTAN		!C5HTAN		!C5HT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C5-1000mb HT,HTAN $c5n1000 $c5c1000|~ C5-1000mb HT,AN!
r

! cluster #6

clear=yes

scale=0
glev=500		!500		!500		!500
gfun=C6HTAN		!C6HTAN		!C6HTAN		!C6HT
cint=60/-6000/-60	!60/0/0		!60/60/6000	!60
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C6-500mb HT,HTAN $c6n500 $c6c500|~ C6-500mb HT,AN!
r

clear=yes

scale=0
glev=1000		!1000		!1000		!1000
gfun=C6HTAN		!C6HTAN		!C6HTAN		!C6HT
cint=30/-3000/-30	!30/0/0		!30/30/3000	!30
line=$can/2/2/1		!$caz/2/2/1	!$cap/2/2/1	!$cch/1/2/1
title=5/-1/~ C6-1000mb HT,HTAN $c6n1000 $c6c1000|~ C6-1000mb HT,AN!
r

ex
EOF
	
		endif

	end

	# begin loop for pct

	foreach mrf_fhr ( 72 96  120  144 )

		if ( $testv > '0' ) then
			echo `date` $yymmdd $cycle_in gdplot for ${mrf_yymmdd} ${mrf_fhr}
		endif

		set ccp=5

		#gdplot << EOF
		#gdplot << EOF  >>/dev/null
		gdplot << EOF  >>$out_name
dev=nc
gvect=
gvcord=PRES
wind=
PROJ=   str/90;-95;0/0;5;0;0
GAREA=  -6;-135;39;5
GAREA=  ${swlat};${swlon};${nelat};${nelon}
map=1
lat=29
text=1/21//hw

gdf=$GRDS_DIR/cluster.${mrf_yymmdd}${cycle_cluster_data}
gdatt=${mrf_yymmdd}/0000F${mrf_fhr} 

clear=yes

ctype=c/f
fint     = 30;70
fline    = $c2blured

scale=0
glev=500
gfun=PCT3
cint=10;30;50;70;90
line=$crbf5b/1/2/1
title=5/-1/~ PROBABILITY OF Z500>5580|~ PRB Z500>5580!
r

clear=yes

ctype=c/f
fint     = 30;70
fline    = $c2blured

scale=0
glev=500
gfun=PCT2
cint=10;30;50;70;90
line=$crbf5b/1/2/1
title=5/-1/~ PROBABILITY OF Z500>5640|~ PRB Z500>5640!
r

clear=yes

ctype=c/f
fint     = 30;70
fline    = $c2blured

scale=0
glev=500
gfun=PCT1
cint=10;30;50;70;90
line=$crbf5b/1/2/1
title=5/-1/~ PROBABILITY OF Z500>5700|~ PRB Z500>5700!
r

clear=yes

ctype=c/f
fint     = 70;110
fline    = $c2red

scale=0
glev=500
gfun=PCT7
cint=10;30;50;70;90
line=$crbf5b/1/2/1
title=5/-1/~ PROBABILITY OF TEND500>30|~ PRB TEND500>30!
r

clear=yes

ctype=c/f
fint     = 70;110
fline    = $c2blu

scale=0
glev=500
gfun=PCT8
cint=10;30;50;70;90
line=$crbr5b/1/2/1
title=5/-1/~ PROBABILITY OF TEND500<-30|~ PRB TEND500<-30!
r

clear=yes

ctype=c/f
fint     = 30;70
fline    = $c2redblu

scale=0
glev=500
gfun=PCT6
cint=10;30;50;70;90
line=$crbr5b/1/2/1
title=5/-1/~ PROBABILITY OF THKN<5400|~ PRB THKN<5400!
r

clear=yes

ctype=c/f
fint     = 70;110
fline    = $c2red

scale=0
glev=500
gfun=PCT4
cint=10;30;50;70;90
line=$crbf5b/1/2/1
title=5/-1/~ PROBABILITY OF THKNAN>60|~ PRB THKNAN>60!
r

clear=yes

ctype=c/f
fint     = 70;110
fline    = $c2blu

scale=0
glev=500
gfun=PCT5
cint=10;30;50;70;90
line=$crbr5b/1/2/1
title=5/-1/~ PROBABILITY OF THKNAN<-60|~ PRB THKNAN<-60!
r

clear=yes

ctype=c/f
fint     = 30;70
fline    = $c2redblu

scale=0
glev=500
gfun=PCT0
cint=10;30;50;70;90
line=$crbr5b/1/2/1
title=5/-1/~ PROBABILITY T850<0C|~ PRB T850<0C!
r

clear=yes

ctype=c/f
fint     = 70;110
fline    = $c2grn

scale=0
glev=500
gfun=PCT9
cint=10;30;50;70;90
line=$crbr5b/1/2/1
title=5/-1/~ PROBABILITY OF RH700>70|~ PRB RH700>70!
r

clear=yes
ctype=c
fint     = 0
fline    = 0

ex
EOF

		# end loop for pct
	end

	if ( $testv > '0' ) then
		echo gpend
	endif

	gpend

	if ( $testv > '0' ) then
		echo move metafile
	endif

	mv Nmeta $META_DIR/."$mdl"_"$mrf_yymmdd"_"$cycle_cluster_meta"_cluster"$suffix"
	mv $META_DIR/."$mdl"_"$mrf_yymmdd"_"$cycle_cluster_meta"_cluster"$suffix" $META_DIR/"$mdl"_"$mrf_yymmdd"_"$cycle_cluster_meta"_cluster"$suffix"

	if ( $testo == '0' ) then

		$BIN_DIR/NA_notify meta ENSEMBLE ${mrf_yymmdd} ${cycle_cluster_meta} 00 X

		$BIN_DIR/meta_transfer $mdl $mrf_yymmdd $cycle_cluster_meta cluster all &

	endif

	if ( $testv > '0' ) then
		echo done
	endif

endif