#!/usr/bin/perl -w
#
# The input file name will have a form similar to:
#  SSEC_AWIPS_NRCAST_10KM_ECON_2010060822_F006_000.GRIB2
# This file is formatted in GRIB2.  This script moves the NRCAST GRIB2
#  files from /data/fxa/LDAD/tmp to /data/fxa/Grid/SBN/rawGrib2 where
#  the AWIPS Grib2Decoder will process them.
#
# Created by
# Jordan Gerth
# Last modified July 1, 2010
# CIMSS/SSEC - Madison, Wisconsin
# http://www.ssec.wisc.edu/~jordang
# jordang@ssec.wisc.edu
#
# and
#
# Jerry Wiedenfeld
# Information Technology Officer
# NWS - Sullivan, Wisconsin
# http://www.crh.noaa.gov/mkx
# jerry.wiedenfeld@noaa.gov

# Create a system to log results of this script
$datedir=`date -u +%Y%m%d`;
chomp $datedir;
$logfile="/preProcessNRCAST.log";
open (LOGNRCAST, ">/data/logs/fxa/$datedir$logfile");

# Record initiation time
print LOGNRCAST "Started ";
print LOGNRCAST `date`;
print LOGNRCAST "\n";

# Remove directory structure from file name
use File::Basename;
$ofina = basename($ARGV[0],"");

# Move to prepare for the Grib2Decoder
print LOGNRCAST `mv /data/fxa/LDAD/tmp/$ofina /data/fxa/Grid/SBN/rawGrib2/.`;

# Signal Grib2Decoder
print LOGNRCAST `ssh fxa@dx3 '/awips/fxa/bin/sendPing GRID_ROUTER LTBA98KWBE'`;

# Close and exit
close (LOGNRCAST);
exit(0);
