#!/usr/bin/perl

foreach $file (@ARGV) {
    next if($file !~ /Z__C_RJTD_\d+_MSM_GPV_Rjp_L-pall_FH00-15_grib2.bin$/);
    next if(-f "$file.nc");

    print  "wgrib2 $file -netcdf $file.nc\n";
    system("wgrib2 $file -netcdf $file.nc");

    $size = -s "$file.nc";
    if($size != 134652740) {
	print("$file.nc: $size --> unlink\n");
	unlink("file.nc");
    }
}
