diff --git a/ush/make_ntc_bull.pl b/ush/make_ntc_bull.pl index c6ca287e..a1d4455e 100755 --- a/ush/make_ntc_bull.pl +++ b/ush/make_ntc_bull.pl @@ -26,13 +26,12 @@ #------------------------------------------------------ if ($ENV{job}) { $job=$ENV{job}; } -if ($ENV{SENDCOM}) { $SENDCOM=$ENV{SENDCOM}; } if ($ENV{SENDDBN}) { $SENDDBN=$ENV{SENDDBN}; } $NArgs = @ARGV; if ($NArgs < 6) { - usage (); - exit; + usage (); + exit; } # @@ -50,201 +49,183 @@ if ( ($Filename eq "") || ($OutputFilename eq "") ) { - usage (); - exit; + usage (); +exit; } # # Create the file for TOC # - if ( $NAME eq "plot" ) { - make_tocplot (); - } - elsif ($NAME eq "redb" ) { - make_tocredb (); - } - else { - make_tocbull (); - } +if ( $NAME eq "plot" ) { + make_tocplot (); +} elsif ($NAME eq "redb" ) { + make_tocredb (); +} else { + make_tocbull (); +} # # - sub usage () { - print "Usage: $0 \n"; + print "Usage: $0 \n"; } sub make_tocbull { - -# -# Attach WMO header -# Get the bytecount of file to insert into the Bulletin Flag Field Seperator. -# - - $ix = 0; - $under = "_"; - open (INFILE, $Filename) or die "Cannot open $Filename"; - - while ($cho=) { - $rec = $rec . $cho; - } - $cho = $rec; - $cho =~ s/\n//g; - $cho =~ s/<<@@/\r\r\n/g; - $cho =~ s/<<@/\r\r\n/g; - $cho =~ s/<//g; - $cho =~ s/\^//g; - $cho =~ s/\$//g; - $cho =~ s/\|/+/g; - $value = 40; - $Outp="$OutputFilename"; - open(OUTFILE, ">$Outp") or die "Cannot open $OutputFilename for output."; - while ($ix == 0) { - $cho = substr($cho,$value); - $value = 38; - $cho =~ s/'1/\&\&/; - $cho =~ s/'0/\&\&/; -# print "cho is $cho"; - ($cho2,$cho) = split(/\&\&/,$cho); - ($cho2,$cho3) = split(/\%/,$cho2); -# print "cho2 is $cho2"; - $ByteCount = length($cho2); - print " length is $ByteCount "; - $BulletinFlagFieldSep = sprintf( "****%10.10d****", $ByteCount); - if ($SENDCOM eq "YES") { + # + # Attach WMO header + # Get the bytecount of file to insert into the Bulletin Flag Field Seperator. + # + $ix = 0; + $under = "_"; + open (INFILE, $Filename) or die "Cannot open $Filename"; + + while ($cho=) { + $rec = $rec . $cho; + } + $cho = $rec; + $cho =~ s/\n//g; + $cho =~ s/<<@@/\r\r\n/g; + $cho =~ s/<<@/\r\r\n/g; + $cho =~ s/<//g; + $cho =~ s/\^//g; + $cho =~ s/\$//g; + $cho =~ s/\|/+/g; + $value = 40; + $Outp="$OutputFilename"; + open(OUTFILE, ">$Outp") or die "Cannot open $OutputFilename for output."; + while ($ix == 0) { + $cho = substr($cho,$value); + $value = 38; + $cho =~ s/'1/\&\&/; + $cho =~ s/'0/\&\&/; + # print "cho is $cho"; + ($cho2,$cho) = split(/\&\&/,$cho); + ($cho2,$cho3) = split(/\%/,$cho2); + # print "cho2 is $cho2"; + $ByteCount = length($cho2); + print " length is $ByteCount "; + $BulletinFlagFieldSep = sprintf( "****%10.10d****", $ByteCount); if ($ByteCount > 50 ) { - print OUTFILE "$BulletinFlagFieldSep\n"; - print OUTFILE $cho2; + print OUTFILE "$BulletinFlagFieldSep\n"; + print OUTFILE $cho2; + } else { + $ix = 1; } - else { - $ix = 1; + } + close OUTFILE; + if ($SENDDBN eq "YES" ) { + # Modified 20051205 by wx11rp to ensure the current production machine is used. + # $dbn_alert="/gpfs/w/nco/dbnet/bin/dbn_alert"; + $dbn_alert=$ENV{'DBNROOT'} . "/bin/dbn_alert"; + $type="GRIB_LOW"; + $job2=$job; + $subtype=$ORIGname; + $file_path=$Outp; + @command = ($dbn_alert, $type, $subtype, $job2, $file_path); + if (system (@command) != 0) { + print "Error alerting: @command \n"; } - } - } - close OUTFILE; - if ($SENDDBN eq "YES" ) { -# Modified 20051205 by wx11rp to ensure the current production machine is used. -# $dbn_alert="/gpfs/w/nco/dbnet/bin/dbn_alert"; - $dbn_alert=$ENV{'DBNROOT'} . "/bin/dbn_alert"; - $type="GRIB_LOW"; - $job2=$job; - $subtype=$ORIGname; - $file_path=$Outp; - @command = ($dbn_alert, $type, $subtype, $job2, $file_path); - if (system (@command) != 0) { - print "Error alerting: @command \n"; - } - } - - close INFILE; - close OUTFILE; - - print "$Filename -> $OutputFilename\n"; -} + } -sub make_tocplot { + close INFILE; + close OUTFILE; -# -# Attach WMO header -# Get the bytecount of file to insert into the Bulletin Flag Field Seperator. -# + print "$Filename -> $OutputFilename\n"; +} - $ix = 0; - $under = "_"; - open (INFILE, $Filename) or die "Cannot open $Filename"; - - while ($cho=) { - $rec = $rec . $cho; - } - $cho = $rec; -# $Outp="$OutputFilename$under$job"; - $Outp="$OutputFilename"; - open(OUTFILE, ">$Outp") or die "Cannot open $OutputFilename for output."; - while ($ix == 0) { - $cho =~ s/\$\$/\&\&/; - ($cho2,$cho) = split(/\&\&/,$cho); -# $cho2 =~ s/@/ /g; -# $cho2 = $cho2 . " "; - $ByteCount = length($cho2); - print " length is $ByteCount "; - $BulletinFlagFieldSep = sprintf( "****%10.10d****", $ByteCount); - if ($SENDCOM eq "YES") { +sub make_tocplot { + # + # Attach WMO header + # Get the bytecount of file to insert into the Bulletin Flag Field Seperator. + # + $ix = 0; + $under = "_"; + open (INFILE, $Filename) or die "Cannot open $Filename"; + + while ($cho=) { + $rec = $rec . $cho; + } + $cho = $rec; + # $Outp="$OutputFilename$under$job"; + $Outp="$OutputFilename"; + open(OUTFILE, ">$Outp") or die "Cannot open $OutputFilename for output."; + while ($ix == 0) { + $cho =~ s/\$\$/\&\&/; + ($cho2,$cho) = split(/\&\&/,$cho); + # $cho2 =~ s/@/ /g; + # $cho2 = $cho2 . " "; + $ByteCount = length($cho2); + print " length is $ByteCount "; + $BulletinFlagFieldSep = sprintf( "****%10.10d****", $ByteCount); if ($ByteCount > 50 ) { - print OUTFILE "$BulletinFlagFieldSep\n"; - print OUTFILE $cho2; + print OUTFILE "$BulletinFlagFieldSep\n"; + print OUTFILE $cho2; + } else { + $ix = 1; } - else { - $ix = 1; + } + close OUTFILE; + if ($SENDDBN eq "YES" ) { + # 20051205 Modified by wx11rp to allow the script to run on any manchine labeled as the production machine + # $dbn_alert="/gpfs/w/nco/dbnet/bin/dbn_alert"; + $dbn_alert=$ENV{'DBNROOT'} . "/bin/dbn_alert"; + $type="GRIB_LOW"; + $subtype=$DATEname; + $job2=$job; + $file_path=$Outp; + @command = ($dbn_alert, $type, $subtype, $job2, $file_path); + if (system (@command) != 0) { + print "Error alerting: @command \n"; } - } - } - close OUTFILE; - if ($SENDDBN eq "YES" ) { -# 20051205 Modified by wx11rp to allow the script to run on any manchine labeled as the production machine -# $dbn_alert="/gpfs/w/nco/dbnet/bin/dbn_alert"; - $dbn_alert=$ENV{'DBNROOT'} . "/bin/dbn_alert"; - $type="GRIB_LOW"; - $subtype=$DATEname; - $job2=$job; - $file_path=$Outp; - @command = ($dbn_alert, $type, $subtype, $job2, $file_path); - if (system (@command) != 0) { - print "Error alerting: @command \n"; - } - } - - close INFILE; - close OUTFILE; - - print "$Filename -> $OutputFilename\n"; + } + + close INFILE; + close OUTFILE; + + print "$Filename -> $OutputFilename\n"; } sub make_tocredb { + # + # Prepare the Redbook graphic for transmission to TOC by removing the AWIPS + # header and creating an NTC header. Get the Bytecount of the file to + # insert into the Bulletin Flag Field Seperator. + # + $ix = 0; + $under = "_"; + open (INFILE, $Filename) or die "Cannot open $Filename"; + + while ($cho=) { + $rec = $rec . $cho; + } + $cho = $rec; + $Outp="$OutputFilename"; + open(OUTFILE, ">$Outp") or die "Cannot open $OutputFilename for output."; + $cho = substr($cho,24); + $ByteCount = length($cho); + print " length is $ByteCount "; + $BulletinFlagFieldSep = sprintf( "****%10.10d****", $ByteCount); + if ($ByteCount > 50 ) { + print OUTFILE "$BulletinFlagFieldSep\n"; + print OUTFILE $cho; + } + close OUTFILE; + if ($SENDDBN eq "YES" ) { + # 20051205 Modified by wx11rp to allow the script to run on any manchine labeled as the production machine + # $dbn_alert="/gpfs/w/nco/dbnet/bin/dbn_alert"; + $dbn_alert=$ENV{'DBNROOT'} . "/bin/dbn_alert"; + $type="GRIB_LOW"; + $subtype=$DATEname; + $job2=$job; + $file_path=$Outp; + @command = ($dbn_alert, $type, $subtype, $job2, $file_path); + if (system (@command) != 0) { + print "Error alerting: @command \n"; + } + } -# -# Prepare the Redbook graphic for transmission to TOC by removing the AWIPS -# header and creating an NTC header. Get the Bytecount of the file to -# insert into the Bulletin Flag Field Seperator. -# + close INFILE; + close OUTFILE; - $ix = 0; - $under = "_"; - open (INFILE, $Filename) or die "Cannot open $Filename"; - - while ($cho=) { - $rec = $rec . $cho; - } - $cho = $rec; - $Outp="$OutputFilename"; - open(OUTFILE, ">$Outp") or die "Cannot open $OutputFilename for output."; - $cho = substr($cho,24); - $ByteCount = length($cho); - print " length is $ByteCount "; - $BulletinFlagFieldSep = sprintf( "****%10.10d****", $ByteCount); - if ($SENDCOM eq "YES") { - if ($ByteCount > 50 ) { - print OUTFILE "$BulletinFlagFieldSep\n"; - print OUTFILE $cho; - - } - } - close OUTFILE; - if ($SENDDBN eq "YES" ) { -# 20051205 Modified by wx11rp to allow the script to run on any manchine labeled as the production machine -# $dbn_alert="/gpfs/w/nco/dbnet/bin/dbn_alert"; - $dbn_alert=$ENV{'DBNROOT'} . "/bin/dbn_alert"; - $type="GRIB_LOW"; - $subtype=$DATEname; - $job2=$job; - $file_path=$Outp; - @command = ($dbn_alert, $type, $subtype, $job2, $file_path); - if (system (@command) != 0) { - print "Error alerting: @command \n"; - } - } - - close INFILE; - close OUTFILE; - - print "$Filename -> $OutputFilename\n"; + print "$Filename -> $OutputFilename\n"; }