#!/usr/local/bin/perl
$num = $#ARGV;
$gzippedfilesdir="/home/echo2/map/field.dumps/ascii.files.gzipped";

if ($num <=-1) {
print"usage: opraingest.loop wildcard(withoutasterisk) topheight derivefields(0=no,1=yes)\n";
}
else {

$wild =$ARGV[0];
$topheight=$ARGV[1];
$derivefields=$ARGV[2];
$lendir=length($gzippedfilesdir)+1;

foreach $file (`ls $gzippedfilesdir/*$wild*Z*`){


chop($file);
# extract out the date and time from the filename
$datestr=substr($file,$lendir+4,7);

print("processing $datestr\n");
# assumes only dealing with 3d files
#print("/home/echo2/map/ascii.files/ingestoprafile $datestr $topheight $derivefields");
system("/home/echo2/map/ascii.files/ingestoprafile $datestr $topheight $derivefields");

}
}
exit(0);
