#!/usr/bin/perl
### check_hdf_size.pl
###
use Class::Struct;
use CGI qw(param);
use Time::Local;
use strict;

my $modis=$ARGV[0];
my $year_1=$ARGV[1];
my $jday_1=$ARGV[2];
my $granule=$ARGV[3];

my $retur_data = 'Failure';
my $inFile = ' ';
my @splitMsg = ' ';
my $filesize = 0;
my $filesize_local = 0;

#my $local_data_dir="/home/oper/Dust/OSPO_Package_Dust_GRIB/input";
my $local_data_dir="/data/Dust/run/input";
my $data_dir= "/data/Dust/input";

my $inPattern="MOD$modis.P$year_1$jday_1.$granule.hdf";


chdir($data_dir);

my @inFileList = `ls -l $inPattern`;


 if (@inFileList ne ' ' ) {
  foreach $inFile (@inFileList) {
     chomp($inFile);
     @splitMsg = split(/\s+/, $inFile);
     $filesize = $splitMsg[4];
     print " filesize = $filesize   \n";
   }
 }
chdir($local_data_dir);

@inFileList = `ls -l $inPattern`;
 if (@inFileList ne ' ' ) {
  foreach $inFile (@inFileList) {
     chomp($inFile);
     @splitMsg = split(/\s+/, $inFile);
     $filesize_local = $splitMsg[4];
     print "filesize_local = $filesize_local $filesize   \n";
     if ($filesize_local  == $filesize ) { 
       $retur_data =' OK'; 
     } 
   } 
 } 

 print "HDF data $inPattern : $retur_data   \n";
   


